[issue11477] Bug in code dispatching based on internal slots

Nick Coghlan report at bugs.python.org
Tue Mar 15 15:01:09 CET 2011


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Armin: yeah, I learned better in the course of trying to fix this misbehaviour in CPython. I've adjusted assorted sq_concat methods to return NotImplemented in the sandbox where I'm working on this, along with modifying abstract.c to correctly cope with that.

Terry: the slot signatures vary, so copying function pointers around isn't really viable. I'm just fixing abstract.c to call the slots in the right order.

The fun part is that historically, CPython didn't check for NotImplemented returns from sq_concat and sq_repeat, so those methods are all written to raise TypeError explicitly, which breaks delegation to __radd__ methods (i.e. exactly the same thing Armin fixed in PyPy).

As far as 2.7 and 3.2 go, I'm thinking a Py3k warning in the next 2.7 release and a CompatibilityWarning (once we have it) in the next 3.2 will be a possibility. However, I want to finish the patch and see the magnitude of the change before deciding what we do with the maintenance versions.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11477>
_______________________________________


More information about the Python-bugs-list mailing list