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
d4d400cb
Kaydet (Commit)
d4d400cb
authored
Nis 18, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
try to initalize all builtin types with PyType_Ready to avoid problems like #5787
üst
baba195e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
16 deletions
+83
-16
test_descr.py
Lib/test/test_descr.py
+12
-0
NEWS
Misc/NEWS
+3
-0
frameobject.c
Objects/frameobject.c
+0
-8
object.c
Objects/object.c
+68
-8
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
d4d400cb
import
__builtin__
import
types
import
types
import
unittest
import
unittest
import
warnings
import
warnings
...
@@ -3895,6 +3896,17 @@ order (MRO) for bases """
...
@@ -3895,6 +3896,17 @@ order (MRO) for bases """
else
:
else
:
self
.
fail
(
"new-style class must have a new-style base"
)
self
.
fail
(
"new-style class must have a new-style base"
)
def
test_builtin_bases
(
self
):
# Make sure all the builtin types can have their base queried without
# segfaulting. See issue #5787.
builtin_types
=
[
tp
for
tp
in
__builtin__
.
__dict__
.
itervalues
()
if
isinstance
(
tp
,
type
)]
for
tp
in
builtin_types
:
object
.
__getattribute__
(
tp
,
"__bases__"
)
if
tp
is
not
object
:
self
.
assertEqual
(
len
(
tp
.
__bases__
),
1
,
tp
)
def
test_mutable_bases_with_failing_mro
(
self
):
def
test_mutable_bases_with_failing_mro
(
self
):
# Testing mutable bases with failing mro...
# Testing mutable bases with failing mro...
class
WorkOnce
(
type
):
class
WorkOnce
(
type
):
...
...
Misc/NEWS
Dosyayı görüntüle @
d4d400cb
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #5787: object.__getattribute__(some_type, "__bases__") segfaulted on
some builtin types.
- Issue #1869: fix a couple of minor round() issues. round(5e15+1)
- Issue #1869: fix a couple of minor round() issues. round(5e15+1)
was giving 5e15+2; round(-0.0) was losing the sign of the zero.
was giving 5e15+2; round(-0.0) was losing the sign of the zero.
...
...
Objects/frameobject.c
Dosyayı görüntüle @
d4d400cb
...
@@ -606,14 +606,6 @@ int _PyFrame_Init()
...
@@ -606,14 +606,6 @@ int _PyFrame_Init()
builtin_object
=
PyString_InternFromString
(
"__builtins__"
);
builtin_object
=
PyString_InternFromString
(
"__builtins__"
);
if
(
builtin_object
==
NULL
)
if
(
builtin_object
==
NULL
)
return
0
;
return
0
;
/*
Traceback objects are not created the normal way (through calling the
type), so PyType_Ready has to be called here.
*/
if
(
PyType_Ready
(
&
PyTraceBack_Type
))
{
Py_DECREF
(
builtin_object
);
return
0
;
}
return
1
;
return
1
;
}
}
...
...
Objects/object.c
Dosyayı görüntüle @
d4d400cb
...
@@ -2033,28 +2033,88 @@ void
...
@@ -2033,28 +2033,88 @@ void
_Py_ReadyTypes
(
void
)
_Py_ReadyTypes
(
void
)
{
{
if
(
PyType_Ready
(
&
PyType_Type
)
<
0
)
if
(
PyType_Ready
(
&
PyType_Type
)
<
0
)
Py_FatalError
(
"Can't initialize
'type'
"
);
Py_FatalError
(
"Can't initialize
type type
"
);
if
(
PyType_Ready
(
&
_PyWeakref_RefType
)
<
0
)
if
(
PyType_Ready
(
&
_PyWeakref_RefType
)
<
0
)
Py_FatalError
(
"Can't initialize
'weakref'
"
);
Py_FatalError
(
"Can't initialize
weakref type
"
);
if
(
PyType_Ready
(
&
PyBool_Type
)
<
0
)
if
(
PyType_Ready
(
&
PyBool_Type
)
<
0
)
Py_FatalError
(
"Can't initialize
'bool'
"
);
Py_FatalError
(
"Can't initialize
bool type
"
);
if
(
PyType_Ready
(
&
PyString_Type
)
<
0
)
if
(
PyType_Ready
(
&
PyString_Type
)
<
0
)
Py_FatalError
(
"Can't initialize
'str'
"
);
Py_FatalError
(
"Can't initialize
str type
"
);
if
(
PyType_Ready
(
&
PyByteArray_Type
)
<
0
)
if
(
PyType_Ready
(
&
PyByteArray_Type
)
<
0
)
Py_FatalError
(
"Can't initialize
'bytes'
"
);
Py_FatalError
(
"Can't initialize
bytearray
"
);
if
(
PyType_Ready
(
&
PyList_Type
)
<
0
)
if
(
PyType_Ready
(
&
PyList_Type
)
<
0
)
Py_FatalError
(
"Can't initialize
'list'
"
);
Py_FatalError
(
"Can't initialize
list
"
);
if
(
PyType_Ready
(
&
PyNone_Type
)
<
0
)
if
(
PyType_Ready
(
&
PyNone_Type
)
<
0
)
Py_FatalError
(
"Can't initialize
type(None)
"
);
Py_FatalError
(
"Can't initialize
None type
"
);
if
(
PyType_Ready
(
&
PyNotImplemented_Type
)
<
0
)
if
(
PyType_Ready
(
&
PyNotImplemented_Type
)
<
0
)
Py_FatalError
(
"Can't initialize type(NotImplemented)"
);
Py_FatalError
(
"Can't initialize NotImplemented type"
);
if
(
PyType_Ready
(
&
PyTraceBack_Type
)
<
0
)
Py_FatalError
(
"Can't initialize traceback type"
);
if
(
PyType_Ready
(
&
PySuper_Type
)
<
0
)
Py_FatalError
(
"Can't initialize super type"
);
if
(
PyType_Ready
(
&
PyBaseObject_Type
)
<
0
)
Py_FatalError
(
"Can't initialize object type"
);
if
(
PyType_Ready
(
&
PyRange_Type
)
<
0
)
Py_FatalError
(
"Can't initialize xrange type"
);
if
(
PyType_Ready
(
&
PyDict_Type
)
<
0
)
Py_FatalError
(
"Can't initialize dict type"
);
if
(
PyType_Ready
(
&
PySet_Type
)
<
0
)
Py_FatalError
(
"Can't initialize set type"
);
if
(
PyType_Ready
(
&
PyUnicode_Type
)
<
0
)
Py_FatalError
(
"Can't initialize unicode type"
);
if
(
PyType_Ready
(
&
PySlice_Type
)
<
0
)
Py_FatalError
(
"Can't initialize slice type"
);
if
(
PyType_Ready
(
&
PyStaticMethod_Type
)
<
0
)
Py_FatalError
(
"Can't initialize static method type"
);
if
(
PyType_Ready
(
&
PyComplex_Type
)
<
0
)
Py_FatalError
(
"Can't initalize complex type"
);
if
(
PyType_Ready
(
&
PyFloat_Type
)
<
0
)
Py_FatalError
(
"Can't initalize float type"
);
if
(
PyType_Ready
(
&
PyBuffer_Type
)
<
0
)
Py_FatalError
(
"Can't initialize buffer type"
);
if
(
PyType_Ready
(
&
PyLong_Type
)
<
0
)
Py_FatalError
(
"Can't initialize long type"
);
if
(
PyType_Ready
(
&
PyInt_Type
)
<
0
)
Py_FatalError
(
"Can't initialize int type"
);
if
(
PyType_Ready
(
&
PyFrozenSet_Type
)
<
0
)
Py_FatalError
(
"Can't initialize frozenset type"
);
if
(
PyType_Ready
(
&
PyProperty_Type
)
<
0
)
Py_FatalError
(
"Can't initialize property type"
);
if
(
PyType_Ready
(
&
PyMemoryView_Type
)
<
0
)
Py_FatalError
(
"Can't initialize memoryview type"
);
if
(
PyType_Ready
(
&
PyTuple_Type
)
<
0
)
Py_FatalError
(
"Can't initalize tuple type"
);
if
(
PyType_Ready
(
&
PyEnum_Type
)
<
0
)
Py_FatalError
(
"Can't initalize enumerate type"
);
if
(
PyType_Ready
(
&
PyReversed_Type
)
<
0
)
Py_FatalError
(
"Can't initalize reversed type"
);
}
}
...
...
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