mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-141370: Fix undefined behavior when using Py_ABS() (GH-141548)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
This commit is contained in:
parent
1d8f3ed2eb
commit
706fdda8b3
6 changed files with 43 additions and 3 deletions
|
|
@ -549,6 +549,17 @@ def test_hex_separator_basics(self):
|
|||
self.assertEqual(three_bytes.hex(':', 2), 'b9:01ef')
|
||||
self.assertEqual(three_bytes.hex(':', 1), 'b9:01:ef')
|
||||
self.assertEqual(three_bytes.hex('*', -2), 'b901*ef')
|
||||
self.assertEqual(three_bytes.hex(sep=':', bytes_per_sep=2), 'b9:01ef')
|
||||
self.assertEqual(three_bytes.hex(sep='*', bytes_per_sep=-2), 'b901*ef')
|
||||
for bytes_per_sep in 3, -3, 2**31-1, -(2**31-1):
|
||||
with self.subTest(bytes_per_sep=bytes_per_sep):
|
||||
self.assertEqual(three_bytes.hex(':', bytes_per_sep), 'b901ef')
|
||||
for bytes_per_sep in 2**31, -2**31, 2**1000, -2**1000:
|
||||
with self.subTest(bytes_per_sep=bytes_per_sep):
|
||||
try:
|
||||
self.assertEqual(three_bytes.hex(':', bytes_per_sep), 'b901ef')
|
||||
except OverflowError:
|
||||
pass
|
||||
|
||||
value = b'{s\005\000\000\000worldi\002\000\000\000s\005\000\000\000helloi\001\000\000\0000'
|
||||
self.assertEqual(value.hex('.', 8), '7b7305000000776f.726c646902000000.730500000068656c.6c6f690100000030')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue