Skip to content

invalid binary/octal in repl #15320

Description

@izabera

this is not particularly important but i accidentally typed 0b12 in the repl and discovered this:

isabella@melon:~$ python
Python 3.14.4 (main, Jun 18 2026, 14:25:02) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 0b12
  File "<python-input-0>", line 1
    0b12
       ^
SyntaxError: invalid digit '2' in binary literal
>>> 
isabella@melon:~$ ipython
Python 3.14.4 (main, Jun 18 2026, 14:25:02) [GCC 15.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.14.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: 0b1
Out[1]: 1

In [2]: 0x123g
  Cell In[2], line 1
    0x123g
        ^
SyntaxError: invalid hexadecimal literal


In [3]: 0b12
   ...: 
   ...:

^ pressing enter won't let me submit the cell

In [3]: (0b12)
   ...: 
   ...:

^ likewise

In [3]: 0b12 + 1
   ...: 
   ...:

^ likewise

In [3]: 0o1239
   ...: 
   ...:

^ likewise

i couldn't find an existing issue on this topic, and i haven't investigated it much, it smells like something is catching a tokenizer error and interpreting it as "this is incomplete"

0b12 and 0o1239 also appear to be highlighted as a single number. i'm guessing pygments is highlighting 0b1 and 2 as separate tokens, both numbers, and the result looks like a single token due to the lack of a separator

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions