We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 538d301 commit 09d6ebdCopy full SHA for 09d6ebd
Lib/test/test_struct.py
@@ -802,6 +802,13 @@ def __init__(self):
802
my_struct = MyStruct()
803
self.assertEqual(my_struct.pack(12345), b'\x30\x39')
804
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
+
812
class MyStruct(struct.Struct):
813
def __new__(cls, arg):
814
self = super().__new__(cls, '>h')
0 commit comments