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
77d12eca
Kaydet (Commit)
77d12eca
authored
Eki 07, 2015
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
prevent unacceptable bases from becoming bases through multiple inheritance (#24806)
üst
51cd53e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
7 deletions
+40
-7
test_descr.py
Lib/test/test_descr.py
+31
-0
NEWS
Misc/NEWS
+3
-0
typeobject.c
Objects/typeobject.c
+6
-7
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
77d12eca
...
...
@@ -4065,6 +4065,37 @@ order (MRO) for bases """
else
:
assert
0
,
"best_base calculation found wanting"
def
test_unsubclassable_types
(
self
):
with
self
.
assertRaises
(
TypeError
):
class
X
(
types
.
NoneType
):
pass
with
self
.
assertRaises
(
TypeError
):
class
X
(
object
,
types
.
NoneType
):
pass
with
self
.
assertRaises
(
TypeError
):
class
X
(
types
.
NoneType
,
object
):
pass
class
O
(
object
):
pass
with
self
.
assertRaises
(
TypeError
):
class
X
(
O
,
types
.
NoneType
):
pass
with
self
.
assertRaises
(
TypeError
):
class
X
(
types
.
NoneType
,
O
):
pass
class
X
(
object
):
pass
with
self
.
assertRaises
(
TypeError
):
X
.
__bases__
=
types
.
NoneType
,
with
self
.
assertRaises
(
TypeError
):
X
.
__bases__
=
object
,
types
.
NoneType
with
self
.
assertRaises
(
TypeError
):
X
.
__bases__
=
types
.
NoneType
,
object
with
self
.
assertRaises
(
TypeError
):
X
.
__bases__
=
O
,
types
.
NoneType
with
self
.
assertRaises
(
TypeError
):
X
.
__bases__
=
types
.
NoneType
,
O
def
test_mutable_bases_with_failing_mro
(
self
):
# Testing mutable bases with failing mro...
...
...
Misc/NEWS
Dosyayı görüntüle @
77d12eca
...
...
@@ -10,6 +10,9 @@ What's New in Python 2.7.11?
Core and Builtins
-----------------
- Issue #24806: Prevent builtin types that are not allowed to be subclassed from
being subclassed through multiple inheritance.
- Issue #24848: Fixed a number of bugs in UTF-7 decoding of misformed data.
- Issue #25003: os.urandom() doesn'
t
use
getentropy
()
on
Solaris
because
...
...
Objects/typeobject.c
Dosyayı görüntüle @
77d12eca
...
...
@@ -1724,6 +1724,12 @@ best_base(PyObject *bases)
if
(
PyType_Ready
(
base_i
)
<
0
)
return
NULL
;
}
if
(
!
PyType_HasFeature
(
base_i
,
Py_TPFLAGS_BASETYPE
))
{
PyErr_Format
(
PyExc_TypeError
,
"type '%.100s' is not an acceptable base type"
,
base_i
->
tp_name
);
return
NULL
;
}
candidate
=
solid_base
(
base_i
);
if
(
winner
==
NULL
)
{
winner
=
candidate
;
...
...
@@ -2148,13 +2154,6 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
Py_DECREF
(
bases
);
return
NULL
;
}
if
(
!
PyType_HasFeature
(
base
,
Py_TPFLAGS_BASETYPE
))
{
PyErr_Format
(
PyExc_TypeError
,
"type '%.100s' is not an acceptable base type"
,
base
->
tp_name
);
Py_DECREF
(
bases
);
return
NULL
;
}
/* Check for a __slots__ sequence variable in dict, and count it */
slots
=
PyDict_GetItemString
(
dict
,
"__slots__"
);
...
...
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