Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-143715: deprecate incomplete initialization of struct.Struct()#143659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
fff147fd2a0345589fbc75e91e87babb2740e4e84b3f36635e576475628aadd979cc18f7492ecdb8f5f2dc8cbefFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -582,11 +582,16 @@ def test_Struct_reinitialization(self): | ||
| # Struct instance. This test can be used to detect the leak | ||
| # when running with regrtest -L. | ||
| s = struct.Struct('i') | ||
| with self.assertWarns(DeprecationWarning): | ||
| s.__init__('ii') | ||
skirpichev marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| self.assertEqual(s.format, 'ii') | ||
| packed = b'\x01\x00\x00\x00\x02\x00\x00\x00' | ||
| self.assertEqual(s.pack(1, 2), packed) | ||
| self.assertEqual(s.unpack(packed), (1, 2)) | ||
| def check_sizeof(self, format_str, number_of_codes): | ||
| # The size of 'PyStructObject' | ||
| totalsize = support.calcobjsize('2n3P1?') | ||
| # The size taken up by the 'formatcode' dynamic array | ||
| totalsize += struct.calcsize('P3n0P') * (number_of_codes + 1) | ||
| support.check_sizeof(self, struct.Struct(format_str), totalsize) | ||
| @@ -790,7 +795,8 @@ class MyStruct(struct.Struct): | ||
| def __init__(self): | ||
| super().__init__('>h') | ||
| with self.assertWarns(DeprecationWarning): | ||
| my_struct = MyStruct() | ||
| self.assertEqual(my_struct.pack(12345), b'\x30\x39') | ||
| def test_repr(self): | ||
| @@ -824,7 +830,8 @@ def test_endian_table_init_subinterpreters(self): | ||
| self.assertListEqual(list(results), [None] * 5) | ||
| def test_operations_on_half_initialized_Struct(self): | ||
| with self.assertWarns(DeprecationWarning): | ||
| S = struct.Struct.__new__(struct.Struct) | ||
| spam = array.array('b', b' ') | ||
| self.assertRaises(RuntimeError, S.iter_unpack, spam) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Calling the ``Struct.__new__()`` without required argument now is deprecated. | ||
| Calling :meth:`~object.__init__` method on initialized :class:`~struct.Struct` | ||
| objects is deprecated. Patch by Sergey B Kirpichev. |
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.