Commit 7195d7f
gh-71810: Fix corner case (length==0) for int.to_bytes() (GH-138739)
```pycon
>>> (0).to_bytes(0, 'big', signed=True)
b''
>>> (-1).to_bytes(0, 'big', signed=True) # was b''
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
(-1).to_bytes(0, 'big', signed=True)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
OverflowError: int too big to convert
```
(cherry picked from commit 011179a)
Co-authored-by: Sergey B Kirpichev <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 72b28ca commit 7195d7f
File tree
3 files changed
+10
-3
lines changed- Lib/test
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
3 files changed
+10
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1322 | 1322 | | |
1323 | 1323 | | |
1324 | 1324 | | |
1325 | | - | |
1326 | 1325 | | |
1327 | | - | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
1328 | 1330 | | |
1329 | 1331 | | |
1330 | 1332 | | |
| 1333 | + | |
1331 | 1334 | | |
1332 | 1335 | | |
1333 | 1336 | | |
1334 | 1337 | | |
1335 | 1338 | | |
| 1339 | + | |
| 1340 | + | |
1336 | 1341 | | |
1337 | 1342 | | |
1338 | 1343 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1041 | 1041 | | |
1042 | 1042 | | |
1043 | 1043 | | |
1044 | | - | |
| 1044 | + | |
1045 | 1045 | | |
1046 | 1046 | | |
1047 | 1047 | | |
| |||
0 commit comments