summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-08-29 22:37:18 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-08-29 22:37:18 (GMT)
commit5ce8f35931402661fa39c0f2dab44354f2a1d677 (patch)
tree1ebf3758fdc4d58ee5f4e91a0bcfe58516062a4a /Lib/ctypes/test
parentfa9211b11dd9b78afbb3dda617267c150ba04cf0 (diff)
downloadcpython-5ce8f35931402661fa39c0f2dab44354f2a1d677.zip
cpython-5ce8f35931402661fa39c0f2dab44354f2a1d677.tar.gz
cpython-5ce8f35931402661fa39c0f2dab44354f2a1d677.tar.bz2
Issue #22098: ctypes' BigEndianStructure and LittleEndianStructure now define an empty __slots__ so that subclasses don't always get an instance dict.
Patch by Claudiu Popa.
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r--Lib/ctypes/test/test_byteswap.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_byteswap.py b/Lib/ctypes/test/test_byteswap.py
index 427bb8b..01c97e8 100644
--- a/Lib/ctypes/test/test_byteswap.py
+++ b/Lib/ctypes/test/test_byteswap.py
@@ -22,6 +22,26 @@ class Test(unittest.TestCase):
setattr(bits, "i%s" % i, 1)
dump(bits)
+ def test_slots(self):
+ class BigPoint(BigEndianStructure):
+ __slots__ = ()
+ _fields_ = [("x", c_int), ("y", c_int)]
+
+ class LowPoint(LittleEndianStructure):
+ __slots__ = ()
+ _fields_ = [("x", c_int), ("y", c_int)]
+
+ big = BigPoint()
+ little = LowPoint()
+ big.x = 4
+ big.y = 2
+ little.x = 2
+ little.y = 4
+ with self.assertRaises(AttributeError):
+ big.z = 42
+ with self.assertRaises(AttributeError):
+ little.z = 24
+
def test_endian_short(self):
if sys.byteorder == "little":
self.assertIs(c_short.__ctype_le__, c_short)