Message285444
While investigating a bug report in one of my libraries (https://github.com/waveform80/picamera/issues/355) I've come across a behaviour that appears in Python 3.6 but not prior versions. Specifically, calling super() in a sub-class of a ctypes scalar type appears to fail at the class definition stage. A minimal test case is as follows:
import ctypes as ct
class SuperTest(ct.c_uint32):
def __repr__(self):
return super().__repr__()
This works happily under python 3.2, 3.4, and 3.5 (that I've tested), and also under 2.7 (with the appropriate modification to super's arguments). However, under 3.6 it elicits the following exception:
Traceback (most recent call last):
File "py36_ctypes.py", line 3, in <module>
class SuperTest(ct.c_uint32):
TypeError: __class__ set to <class '__main__.SuperTest'> defining 'SuperTest' as <class '__main__.SuperTest'>
Reading through the "What's New" list in 3.6, I thought this might be something to do with the PEP-487 implementation (given it modified class construction), but having read through the PEP and associated patches I'm not so sure as I can't see anything that affects the setting of the "__class__" attribute (but don't rule it out on that basis; I'm no expert!).
I'll admit that sub-classing one of ctypes' scalar types is a little odd, but given this works in prior versions and there doesn't appear to be anything in the documentation banning the practice (that I've found?) this might constitute a bug? |
|
Date |
User |
Action |
Args |
2017-01-13 22:10:22 | Dave Jones | set | recipients:
+ Dave Jones |
2017-01-13 22:10:22 | Dave Jones | set | messageid: <1484345422.14.0.967631121608.issue29270@psf.upfronthosting.co.za> |
2017-01-13 22:10:22 | Dave Jones | link | issue29270 messages |
2017-01-13 22:10:21 | Dave Jones | create | |
|