Hi Brett,

On Mon, Apr 17, 2006 at 05:34:16PM -0700, Brett Cannon wrote:
> +       if (meth == self) {
> +               PyErr_SetString(PyExc_RuntimeError,
> +                               "recursive __call__ definition");
> +               return NULL;
> +       }

This is not the proper way, as it can be worked around with a pair of
objects whose __call__ point to each other.  The solution is to use the
counter of Py_{Enter,Leave}RecursiveCall(), as was done for old-style
classes (see classobject.c).

By the way, this is a known problem: the example you show is
Lib/test/crashers/infinite_rec_3.py, and the four other
infinite_rec_*.py are all slightly more subtle ways to trigger a similar
infinite loop in C.  They point to the SF bug report at
http://python.org/sf/1202533, where we discuss the problem in general.
Basically, someone should try to drop many
Py_{Enter,Leave}RecursiveCall() pairs in the source until all the
currently-known bugs go away, and then measure if this has a noticeable
performance impact.


A bientot,

Mr. 8 Of The 12 Files In That Directory
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to