Clement Rouault <pyt...@hakril.net> added the comment:

Hello,

As this issue may never be fixed for python3.6. I wanted to post a solution to 
bypass the bug. It may be useful for the next person stumbling on this as I 
have.

The __class__ closure is only created if a function use the word super(). This 
closure allow to call super() without argument.

By using another name than super() the closure is not created and your code can 
work. Only downside is that you need to call super in its explicit form 
super(Cls, self). But it is better that not working at all (and it is 
compatible python2).

Here is a sample:


super_bypass_issue29270 = super

class Something(ctypes.c_ulong):
  def __repr__(self):
    return "BYPASS: " + super_bypass_issue29270(Something, self).__repr__()

s = Something(42)
print(s)

BYPASS: <Something object at 0x00000134C9BA6848>

----------

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

Reply via email to