This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients bup, josh.r, ncoghlan, xiang.zhang
Date 2017-03-31.03:24:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Right, there's a very similar instance-method-reuse related problem described in, where ctypes re-uses a class namespace is define a swapped-endianness version of the originally defined class.

The easiest place to deflect conflicts is at the point where bound instance methods are created:

>>> bound_method = MyList().insert
>>> bound_method.__self__.__class__
<class '__main__.MyList'>
>>> bound_method.__func__.__closure__[0].cell_contents
<class '__main__.MyList'>
>>> bound_method.__self__.__class__ is bound_method.__func__.__closure__[0].cell_contents

However, that method of detection only works for plain instance methods that only close over the `__class__` variable: as soon as you wrap them in a decorator, you may not have easy access to the `__closure__` attribute any more, and if the method has closure references to more than just `__class__`, then it's a bit more work to find the right closure index from outside the function.
Date User Action Args
2017-03-31 03:24:46ncoghlansetrecipients: + ncoghlan, josh.r, xiang.zhang, bup
2017-03-31 03:24:46ncoghlansetmessageid: <>
2017-03-31 03:24:46ncoghlanlinkissue29944 messages
2017-03-31 03:24:45ncoghlancreate