summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2025-04-23 13:38:24 (GMT)
committerGitHub <noreply@github.com>2025-04-23 13:38:24 (GMT)
commit85f89cb3e6bea6022cb58ffda560cf435f0adf94 (patch)
treed387f23e31da5942f1ca15b70e254e0c4b939010 /Lib/test/test_struct.py
parent41dec4158d880a3fd200a84683521fe4ea618992 (diff)
downloadcpython-85f89cb3e6bea6022cb58ffda560cf435f0adf94.zip
cpython-85f89cb3e6bea6022cb58ffda560cf435f0adf94.tar.gz
cpython-85f89cb3e6bea6022cb58ffda560cf435f0adf94.tar.bz2
gh-121249: adjust formatting codes for complex types in struct/ctypes (#132827)
* F - for float _Complex * D - for double _Complex * G - for long double _Complex (not supported by the struct module)
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r--Lib/test/test_struct.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index b99391e..a410fd5 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -23,7 +23,7 @@ INF = float('inf')
NAN = float('nan')
try:
- struct.pack('C', 1j)
+ struct.pack('D', 1j)
have_c_complex = True
except struct.error:
have_c_complex = False
@@ -801,23 +801,23 @@ class StructTest(ComplexesAreIdenticalMixin, unittest.TestCase):
values = [complex(*_) for _ in combinations([1, -1, 0.0, -0.0, 2,
-3, INF, -INF, NAN], 2)]
for z in values:
- for f in ['E', 'C', '>E', '>C', '<E', '<C']:
+ for f in ['F', 'D', '>F', '>D', '<F', '<D']:
with self.subTest(z=z, format=f):
round_trip = struct.unpack(f, struct.pack(f, z))[0]
self.assertComplexesAreIdentical(z, round_trip)
@unittest.skipIf(have_c_complex, "requires no C11 complex type support")
def test_c_complex_error(self):
- msg1 = "'E' format not supported on this system"
- msg2 = "'C' format not supported on this system"
+ msg1 = "'F' format not supported on this system"
+ msg2 = "'D' format not supported on this system"
with self.assertRaisesRegex(struct.error, msg1):
- struct.pack('E', 1j)
+ struct.pack('F', 1j)
with self.assertRaisesRegex(struct.error, msg1):
- struct.unpack('E', b'1')
+ struct.unpack('F', b'1')
with self.assertRaisesRegex(struct.error, msg2):
- struct.pack('C', 1j)
+ struct.pack('D', 1j)
with self.assertRaisesRegex(struct.error, msg2):
- struct.unpack('C', b'1')
+ struct.unpack('D', b'1')
class UnpackIteratorTest(unittest.TestCase):