ApostolFet · GitHub

Bug report

Bug description:

Code for demonstration:

>>> b"%i" % "str"
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    b"%i" % "str"
    ~~~~~~^~~~~~~
TypeError: %d format: a real number is required, not str

Expected error message text:

TypeError: %i format: a real number is required, not str

Also for strings this message is output correctly:

>>> "%i" % "str"
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    "%i" % "str"
    ~~~~~^~~~~~~
TypeError: %i format: a real number is required, not str

I would like to send a PR to fix this.

CPython versions tested on:

3.12, 3.13, 3.14, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗