diff options
| author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-06-26 10:12:01 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-26 10:12:01 (GMT) |
| commit | 17ed560fcd0a1442485f9bd48884bbe412f35abc (patch) | |
| tree | a6d11a5d9ea388f6552e3898aa38b1ea9f98ce8c /Lib/test/test_struct.py | |
| parent | 27934bef2dd9878e04707f090ff5c1ede3278aee (diff) | |
| download | cpython-17ed560fcd0a1442485f9bd48884bbe412f35abc.zip cpython-17ed560fcd0a1442485f9bd48884bbe412f35abc.tar.gz cpython-17ed560fcd0a1442485f9bd48884bbe412f35abc.tar.bz2 | |
GH-94254: Make _struct module types immutable (#94269)
Diffstat (limited to 'Lib/test/test_struct.py')
| -rw-r--r-- | Lib/test/test_struct.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 8f14ed3..ab73877 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -689,6 +689,18 @@ class StructTest(unittest.TestCase): self.assertIsNone( module_ref(), "_struct module was not garbage collected") + @support.cpython_only + def test__struct_types_immutable(self): + # See https://github.com/python/cpython/issues/94254 + + Struct = struct.Struct + unpack_iterator = type(struct.iter_unpack("b", b'x')) + for cls in (Struct, unpack_iterator): + with self.subTest(cls=cls): + with self.assertRaises(TypeError): + cls.x = 1 + + def test_issue35714(self): # Embedded null characters should not be allowed in format strings. for s in '\0', '2\0i', b'\0': |
