Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3a74ce20
Kaydet (Commit)
3a74ce20
authored
Nis 28, 2014
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #13204: Calling sys.flags.__new__ would crash the interpreter, now it raises a TypeError.
üst
6cd08d62
871dfc41
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
3 deletions
+33
-3
test_sys.py
Lib/test/test_sys.py
+20
-0
NEWS
Misc/NEWS
+3
-0
sysmodule.c
Python/sysmodule.c
+10
-3
No files found.
Lib/test/test_sys.py
Dosyayı görüntüle @
3a74ce20
...
@@ -519,6 +519,26 @@ class SysModuleTest(unittest.TestCase):
...
@@ -519,6 +519,26 @@ class SysModuleTest(unittest.TestCase):
self
.
assertTrue
(
repr
(
sys
.
flags
))
self
.
assertTrue
(
repr
(
sys
.
flags
))
self
.
assertEqual
(
len
(
sys
.
flags
),
len
(
attrs
))
self
.
assertEqual
(
len
(
sys
.
flags
),
len
(
attrs
))
def
assert_raise_on_new_sys_type
(
self
,
sys_attr
):
# Users are intentionally prevented from creating new instances of
# sys.flags, sys.version_info, and sys.getwindowsversion.
attr_type
=
type
(
sys_attr
)
with
self
.
assertRaises
(
TypeError
):
attr_type
()
with
self
.
assertRaises
(
TypeError
):
attr_type
.
__new__
(
attr_type
)
def
test_sys_flags_no_instantiation
(
self
):
self
.
assert_raise_on_new_sys_type
(
sys
.
flags
)
def
test_sys_version_info_no_instantiation
(
self
):
self
.
assert_raise_on_new_sys_type
(
sys
.
version_info
)
def
test_sys_getwindowsversion_no_instantiation
(
self
):
# Skip if not being run on Windows.
test
.
support
.
get_attribute
(
sys
,
"getwindowsversion"
)
self
.
assert_raise_on_new_sys_type
(
sys
.
getwindowsversion
())
def
test_clear_type_cache
(
self
):
def
test_clear_type_cache
(
self
):
sys
.
_clear_type_cache
()
sys
.
_clear_type_cache
()
...
...
Misc/NEWS
Dosyayı görüntüle @
3a74ce20
...
@@ -57,6 +57,9 @@ Core and Builtins
...
@@ -57,6 +57,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #13204: Calling sys.flags.__new__ would crash the interpreter,
now it raises a TypeError.
- Issue #19385: Make operations on a closed dbm.dumb database always raise the
- Issue #19385: Make operations on a closed dbm.dumb database always raise the
same exception.
same exception.
...
...
Python/sysmodule.c
Dosyayı görüntüle @
3a74ce20
...
@@ -1622,6 +1622,7 @@ PyObject *
...
@@ -1622,6 +1622,7 @@ PyObject *
_PySys_Init
(
void
)
_PySys_Init
(
void
)
{
{
PyObject
*
m
,
*
sysdict
,
*
version_info
;
PyObject
*
m
,
*
sysdict
,
*
version_info
;
int
res
;
m
=
PyModule_Create
(
&
sysmodule
);
m
=
PyModule_Create
(
&
sysmodule
);
if
(
m
==
NULL
)
if
(
m
==
NULL
)
...
@@ -1629,7 +1630,6 @@ _PySys_Init(void)
...
@@ -1629,7 +1630,6 @@ _PySys_Init(void)
sysdict
=
PyModule_GetDict
(
m
);
sysdict
=
PyModule_GetDict
(
m
);
#define SET_SYS_FROM_STRING_BORROW(key, value) \
#define SET_SYS_FROM_STRING_BORROW(key, value) \
do { \
do { \
int res; \
PyObject *v = (value); \
PyObject *v = (value); \
if (v == NULL) \
if (v == NULL) \
return NULL; \
return NULL; \
...
@@ -1640,7 +1640,6 @@ _PySys_Init(void)
...
@@ -1640,7 +1640,6 @@ _PySys_Init(void)
} while (0)
} while (0)
#define SET_SYS_FROM_STRING(key, value) \
#define SET_SYS_FROM_STRING(key, value) \
do { \
do { \
int res; \
PyObject *v = (value); \
PyObject *v = (value); \
if (v == NULL) \
if (v == NULL) \
return NULL; \
return NULL; \
...
@@ -1759,6 +1758,9 @@ _PySys_Init(void)
...
@@ -1759,6 +1758,9 @@ _PySys_Init(void)
/* prevent user from creating new instances */
/* prevent user from creating new instances */
VersionInfoType
.
tp_init
=
NULL
;
VersionInfoType
.
tp_init
=
NULL
;
VersionInfoType
.
tp_new
=
NULL
;
VersionInfoType
.
tp_new
=
NULL
;
res
=
PyDict_DelItemString
(
VersionInfoType
.
tp_dict
,
"__new__"
);
if
(
res
<
0
&&
PyErr_ExceptionMatches
(
PyExc_KeyError
))
PyErr_Clear
();
/* implementation */
/* implementation */
SET_SYS_FROM_STRING
(
"implementation"
,
make_impl_info
(
version_info
));
SET_SYS_FROM_STRING
(
"implementation"
,
make_impl_info
(
version_info
));
...
@@ -1772,7 +1774,9 @@ _PySys_Init(void)
...
@@ -1772,7 +1774,9 @@ _PySys_Init(void)
/* prevent user from creating new instances */
/* prevent user from creating new instances */
FlagsType
.
tp_init
=
NULL
;
FlagsType
.
tp_init
=
NULL
;
FlagsType
.
tp_new
=
NULL
;
FlagsType
.
tp_new
=
NULL
;
res
=
PyDict_DelItemString
(
FlagsType
.
tp_dict
,
"__new__"
);
if
(
res
<
0
&&
PyErr_ExceptionMatches
(
PyExc_KeyError
))
PyErr_Clear
();
#if defined(MS_WINDOWS)
#if defined(MS_WINDOWS)
/* getwindowsversion */
/* getwindowsversion */
...
@@ -1783,6 +1787,9 @@ _PySys_Init(void)
...
@@ -1783,6 +1787,9 @@ _PySys_Init(void)
/* prevent user from creating new instances */
/* prevent user from creating new instances */
WindowsVersionType
.
tp_init
=
NULL
;
WindowsVersionType
.
tp_init
=
NULL
;
WindowsVersionType
.
tp_new
=
NULL
;
WindowsVersionType
.
tp_new
=
NULL
;
res
=
PyDict_DelItemString
(
WindowsVersionType
.
tp_dict
,
"__new__"
);
if
(
res
<
0
&&
PyErr_ExceptionMatches
(
PyExc_KeyError
))
PyErr_Clear
();
#endif
#endif
/* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
/* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment