Nick Coghlan <ncogh...@gmail.com> added the comment:

>From VA's description of the intended use case, this actually sounds a bit 
>like a variant of https://bugs.python.org/issue29944: one reason that 
>replacing C with a new dynamically constructed type won't work reliably is 
>because some of the methods might have captured references to the original 
>type via closure cells, so zero-arg super() will still fail, even if you 
>rebind the name at the module level.

Even __set_name__ can't reliably help with that, since it would rely on every 
descriptor passing on the __set_name__ call to wrapped objects.

While the problem likely isn't fixable for the class-cloning case, we may be 
able to do something about the class-replacement case by exposing the zero-arg 
super() class cell as an attribute on the class object.

If we did that, then methods on the original class could be pointed at the new 
class by doing "original_class.__classcell__.cell_contents = new_class".

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32768>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to