[Python-Dev] Strange bug only happens with Python 2.2
Gerhard Häring
haering_python@gmx.de
Sat, 28 Sep 2002 00:53:50 +0200
* Gerhard Häring <gerhard.haering@gmx.de> [2002-09-28 00:07 +0200]:
> * Michael Hudson <mwh@python.net> [2002-09-27 16:39 +0100]:
> > On Fri, 27 Sep 2002, Gerhard Häring wrote:
> >
> > > This is somewhat off-topic, but I'm hoping maybe someone can give a hint
> > > why this only happens on Python 2.2.1.
> >
> > Guessing, but the (Jeremy's?) changes I recently backported to
> > classobject.c on the release22-maint branch might relate to this.
>
> Maybe. I've not viewed the control flow in a debugger, but my tries to come up
> with a minimalistic test case and my gut feeling says that this piece of code
> has something to do with it:
>
> static PyObject *PgLargeObject_getattr(PgLargeObject *self, char* attr)
> {
> PyObject *res;
>
> res = Py_FindMethod(PgLargeObject_methods, (PyObject *)self, attr);
> if (res != NULL)
> return res;
> PyErr_Clear();
>
> if (strcmp(attr, "closed") == 0)
> return Py_BuildValue("l", (long)(self->lo_fd == -1));
>
> if (!strcmp(attr, "__module__"))
> return Py_BuildValue("s", MODULE_NAME);
>
> if (!strcmp(attr, "__class__")) {
> printf("__class__ accessed!\n");
> return Py_BuildValue("s", self->ob_type->tp_name);
> }
>
> return PyMember_Get((char *)self, PgLargeObject_members, attr);
> }
>
> from which I can see that isinstance tries to access the __class__ attribute.
> Am I supposed to /not/ provide a __class__ attribute for classic types?
>
> I haven't looked into the python22-maint changelogs yet, but I couldn't find
> any related registered SF bug.
Ok, I've now further narrowed down this isinstance issue:
python22-maint ==> bug does not appear
python22-maint with abstract.c from Python 2.2.1 ==> bug appears
So for what it's worth (i. e. not much), I'd say please /do/ include the
abstract.c changes into the upcoming Python 2.2.2 :-)
-- Gerhard