Message290889
Right, there's a very similar instance-method-reuse related problem described in http://bugs.python.org/issue29270, 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
False
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:46 | ncoghlan | set | recipients:
+ ncoghlan, josh.r, xiang.zhang, bup |
2017-03-31 03:24:46 | ncoghlan | set | messageid: <1490930686.43.0.994523797767.issue29944@psf.upfronthosting.co.za> |
2017-03-31 03:24:46 | ncoghlan | link | issue29944 messages |
2017-03-31 03:24:45 | ncoghlan | create | |
|