Repository navigation
gh-121249: Deprecate using F/D type codes in the struct module #152309
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
9ca0a71
c5b52c0
f2e3f8e
87d0ea7
a2c5ff8
236dab3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| import unittest | ||
| import struct | ||
| import sys | ||
| import warnings | ||
| import weakref | ||
|
|
||
| from test import support | ||
|
|
@@ -995,14 +996,25 @@ def test_c_complex_round_trip(self): | |
| values = [complex(*_) for _ in combinations([1, -1, 0.0, -0.0, 2, | ||
| -3, INF, -INF, NAN], 2)] | ||
| for z in values: | ||
| for f in [ | ||
| 'F', 'D', 'Zf', 'Zd', | ||
| '>F', '>D', '>Zf', '>Zd', | ||
| '<F', '<D', '<Zf', '<Zd', | ||
| ]: | ||
| for f in ['Zf', 'Zd', '>Zf', '>Zd', '<Zf', '<Zd']: | ||
| with self.subTest(z=z, format=f): | ||
| round_trip = struct.unpack(f, struct.pack(f, z))[0] | ||
| self.assertComplexesAreIdentical(z, round_trip) | ||
| for f in ['F', 'D', '>F', '>D', '<F', '<D']: | ||
| z = 1+1j | ||
| with self.subTest(format=f): | ||
|
skirpichev marked this conversation as resolved.
Outdated
|
||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("error", DeprecationWarning) | ||
| self.assertRaises(DeprecationWarning, struct.pack, f, z) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already check
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do this in other places. |
||
| with warnings.catch_warnings(): | ||
| with self.assertWarns(DeprecationWarning): | ||
| b = struct.pack(f, z) | ||
| with warnings.catch_warnings(): | ||
|
skirpichev marked this conversation as resolved.
Outdated
|
||
| warnings.simplefilter("error", DeprecationWarning) | ||
| self.assertRaises(DeprecationWarning, struct.unpack, f, b) | ||
| with self.assertWarns(DeprecationWarning): | ||
| round_trip = struct.unpack(f, b)[0] | ||
| self.assertComplexesAreIdentical(z, round_trip) | ||
|
|
||
| @unittest.skipIf( | ||
| support.is_android or support.is_apple_mobile, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Deprecate using ``'F'`` and ``'D'`` type codes in the :mod:`struct`. | ||
|
skirpichev marked this conversation as resolved.
Outdated
|
||
Uh oh!
There was an error while loading. Please reload this page.