]> granicus.if.org Git - python/commitdiff
Subtle change to make None.__class__ work:
authorGuido van Rossum <guido@python.org>
Thu, 16 Aug 2001 08:27:33 +0000 (08:27 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 16 Aug 2001 08:27:33 +0000 (08:27 +0000)
- 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.

Objects/descrobject.c
Objects/typeobject.c

index 40629f6c24ae16327ecf7e6b012c62805682bba8..a2ecde5b7e527738c0cf9478880edab29b42e634 100644 (file)
@@ -91,9 +91,9 @@ wrapper_repr(PyWrapperDescrObject *descr)
 
 static int
 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);
                *pres = (PyObject *)descr;
                return 1;
index 8103205f766832c64254de562bb3e88347fc3628..30e693ab91a50c4f11f2773d1969ab2f0f368e49 100644 (file)
@@ -1862,8 +1862,6 @@ wrap_descr_get(PyObject *self, PyObject *args, void *wrapped)
 
        if (!PyArg_ParseTuple(args, "O|O", &obj, &type))
                return NULL;
-       if (type == NULL)
-               type = (PyObject *)obj->ob_type;
        return (*func)(self, obj, type);
 }