SIGN IN SIGN UP
python / cpython UNCLAIMED

The Python programming language

72153 0 0 Python

gh-71810: Fix corner case (length==0) for int.to_bytes() (#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
```

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
S
Sergey B Kirpichev committed
011179a79a0d7b93ce074b25b0819e96b6dd3315
Parent: a1707e4
Committed by GitHub <noreply@github.com> on 9/11/2025, 10:30:53 AM