New submission from Armin Rigo <[EMAIL PROTECTED]>:

There is a bunch of obscure behavior caused by the use of
PyObject_GetAttr() to get special method from objects.  This is wrong
because special methods should only be looked up in object types, not on
the objects themselves (i.e. with PyType_Lookup()).

Here is one example caused by the PyObject_GetAttr() found in
PyObject_IsInstance():

import abc
>>> isinstance(5, abc.ABCMeta)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    RuntimeError: maximum recursion depth exceeded while calling a
Python object

This occurs because it ends up trying to call the unbound method
abc.ABCMeta.__instancecheck__(5).  But this first requires checking if
"5" is indeed an instance of abc.ABCMeta... cycle.

Obviously this is just an example; all PyObject_GetAttr() would
potentially need to be reviewed.

----------
messages: 70431
nosy: arigo
severity: normal
status: open
title: PyObject_GetAttr() to get special methods

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3471>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to