Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a8c60f4

Browse files
committed
tp_new_wrapper(): A subtle change in the check for safe use.
Allow staticbase != type, as long as their tp_new slots are the same.
1 parent f21c6be commit a8c60f4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Objects/typeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
23032303
staticbase = subtype;
23042304
while (staticbase && (staticbase->tp_flags & Py_TPFLAGS_HEAPTYPE))
23052305
staticbase = staticbase->tp_base;
2306-
if (staticbase != type) {
2306+
if (staticbase->tp_new != type->tp_new) {
23072307
PyErr_Format(PyExc_TypeError,
23082308
"%s.__new__(%s) is not safe, use %s.__new__()",
23092309
type->tp_name,

0 commit comments

Comments
 (0)