[New-bugs-announce] [issue16070] Structure and native Structure (LittleEndianStructure on Windows) supports __slots__, but BigEndianStructure doesn't
HCT
report at bugs.python.org
Fri Sep 28 05:19:04 CEST 2012
New submission from HCT:
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
----------
components: ctypes
files: slots_test.py
messages: 171402
nosy: hct
priority: normal
severity: normal
status: open
title: Structure and native Structure (LittleEndianStructure on Windows) supports __slots__, but BigEndianStructure doesn't
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file27323/slots_test.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16070>
_______________________________________
More information about the New-bugs-announce
mailing list