diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-09-25 13:32:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-25 13:32:48 (GMT) |
commit | c8c0afc7137ab9f22bf59d591084948ca967c97c (patch) | |
tree | 60cfb58ebb2efefdc00cd339a4f9b545e35bccea /Lib/test/test_struct.py | |
parent | f5f047aa628caeca680745c55e24519f06aa6724 (diff) | |
download | cpython-c8c0afc7137ab9f22bf59d591084948ca967c97c.zip cpython-c8c0afc7137ab9f22bf59d591084948ca967c97c.tar.gz cpython-c8c0afc7137ab9f22bf59d591084948ca967c97c.tar.bz2 |
GH-78724: Initialize struct.Struct in __new__ (GH-94532)
Closes https://github.com/python/cpython/issues/75960
Closes https://github.com/python/cpython/issues/78724
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r-- | Lib/test/test_struct.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index ab73877..b0f11af 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -700,6 +700,20 @@ class StructTest(unittest.TestCase): with self.assertRaises(TypeError): cls.x = 1 + @support.cpython_only + def test__struct_Struct__new__initialized(self): + # See https://github.com/python/cpython/issues/78724 + + s = struct.Struct.__new__(struct.Struct, "b") + s.unpack_from(b"abcd") + + @support.cpython_only + def test__struct_Struct_subclassing(self): + class Bob(struct.Struct): + pass + + s = Bob("b") + s.unpack_from(b"abcd") def test_issue35714(self): # Embedded null characters should not be allowed in format strings. |