mirror of
https://github.com/python/cpython.git
synced 2024-11-26 19:34:19 +08:00
Subtle change to make None.__class__ work:
- descrobject.c:descr_check(): only believe None means the same as NULL if the type given is None's type. - typeobject.c:wrap_descr_get(): don't "conventiently" default an absent type to the type of the object argument. Let the called function figure it out.
This commit is contained in:
parent
f6309e8ecf
commit
8098ddbe81
@ -91,9 +91,9 @@ wrapper_repr(PyWrapperDescrObject *descr)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
descr_check(PyDescrObject *descr, PyObject *obj, PyTypeObject *type,
|
descr_check(PyDescrObject *descr, PyObject *obj, PyTypeObject *type,
|
||||||
PyObject **pres)
|
PyObject **pres)
|
||||||
{
|
{
|
||||||
if (obj == NULL || obj == Py_None) {
|
if (obj == NULL || (obj == Py_None && type != Py_None->ob_type)) {
|
||||||
Py_INCREF(descr);
|
Py_INCREF(descr);
|
||||||
*pres = (PyObject *)descr;
|
*pres = (PyObject *)descr;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1862,8 +1862,6 @@ wrap_descr_get(PyObject *self, PyObject *args, void *wrapped)
|
|||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O|O", &obj, &type))
|
if (!PyArg_ParseTuple(args, "O|O", &obj, &type))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (type == NULL)
|
|
||||||
type = (PyObject *)obj->ob_type;
|
|
||||||
return (*func)(self, obj, type);
|
return (*func)(self, obj, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user