Issue 16070: Structure and native Structure (LittleEndianStructure on Windows) supports slots, but BigEndianStructure doesn't (original) (raw)

using official CPython 3.2.3 with a simple demonstration script (attached) to demonstrate inconsistency between ctypes structures

from ctypes import *

class cbs( BigEndianStructure ): slots = tuple() def init( self, *args, **kw ): super().init( *args, **kw ) self.a = 11

class cls( LittleEndianStructure ): slots = tuple() def init( self, *args, **kw ): super().init( *args, **kw ) self.a = 11

class cs( Structure ): slots = tuple() def init( self, *args, **kw ): super().init( *args, **kw ) self.a = 11

try : cbs1=cbs() except AttributeError as e: print(e)

try : cls1=cls() except AttributeError as e: print(e)

try : cs=cs() except AttributeError as e: print(e)

yields

'cls' object has no attribute 'a' 'cs' object has no attribute 'a'

I expect cbs to throw error too, but itwent through the initalization and silently ignored the slots defined in the class