Skip to content

Commit 09d6ebd

Browse files
committed
+test new idiom
1 parent 538d301 commit 09d6ebd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/test/test_struct.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,13 @@ def __init__(self):
802802
my_struct = MyStruct()
803803
self.assertEqual(my_struct.pack(12345), b'\x30\x39')
804804

805+
# New way, no warnings:
806+
class MyStruct(struct.Struct):
807+
def __new__(cls):
808+
return super().__new__(cls, '>h')
809+
my_struct = MyStruct()
810+
self.assertEqual(my_struct.pack(12345), b'\x30\x39')
811+
805812
class MyStruct(struct.Struct):
806813
def __new__(cls, arg):
807814
self = super().__new__(cls, '>h')

0 commit comments

Comments
 (0)