Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

IndexError on REPL startup in _pyrepl/reader.py with Python 3.13.0b1+ and a custom sys.ps1 set in a PYTHONSTARTUP file #118835

Closed
Labels
3.13bugs and security fixestopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error
@mgedmin

Description

@mgedmin

Bug report

Bug description:

I compiled Python 3.13 (commitd86b494, the current tip of the 3.13 branch), and installed it into ~/opt/python313. When I runpython3.13 with no arguments, I get this:

Python3.13.0b1+ (heads/3.13:d86b494117,May92024,15:23:21) [GCC13.2.0]onlinuxType"help","copyright","credits"or"license"formoreinformation.Traceback (mostrecentcalllast):File"<frozen runpy>",line198,in_run_module_as_mainFile"<frozen runpy>",line88,in_run_codeFile"/home/mg/opt/python313/lib/python3.13/_pyrepl/__main__.py",line47,in<module>interactive_console()~~~~~~~~~~~~~~~~~~~^^File"/home/mg/opt/python313/lib/python3.13/_pyrepl/__main__.py",line44,ininteractive_consolereturnrun_interactive(mainmodule)File"/home/mg/opt/python313/lib/python3.13/_pyrepl/simple_interact.py",line138,inrun_multiline_interactive_consolestatement,contains_pasted_code=multiline_input(more_lines,ps1,ps2)~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^File"/home/mg/opt/python313/lib/python3.13/_pyrepl/readline.py",line301,inmultiline_inputreturnreader.readline(),reader.was_paste_mode_activated~~~~~~~~~~~~~~~^^File"/home/mg/opt/python313/lib/python3.13/_pyrepl/reader.py",line646,inreadlineself.prepare()~~~~~~~~~~~~^^File"/home/mg/opt/python313/lib/python3.13/_pyrepl/historical_reader.py",line285,inpreparesuper().prepare()~~~~~~~~~~~~~~~^^File"/home/mg/opt/python313/lib/python3.13/_pyrepl/reader.py",line521,inprepareself.calc_screen()~~~~~~~~~~~~~~~~^^File"/home/mg/opt/python313/lib/python3.13/_pyrepl/completing_reader.py",line259,incalc_screenscreen=super().calc_screen()File"/home/mg/opt/python313/lib/python3.13/_pyrepl/reader.py",line299,incalc_screenself.cxy=self.pos2xy()~~~~~~~~~~~^^File"/home/mg/opt/python313/lib/python3.13/_pyrepl/reader.py",line474,inpos2xyp,l2=self.screeninfo[y]~~~~~~~~~~~~~~~^^^IndexError:listindexoutofrange

and it exits with status code 1.

My terminal is currently 126 columns by 45 lines, and I have a custom PYTHONSTARTUP environment file pointing to ~/.python, whichyou can see in this GH repo. It sets up some conveniences for the old REPL (colorful prompt, rlcompleter-based tab-completion, persistent readline history).

RunningPYTHONSTARTUP= python3.13 fixes the IndexError.

By commenting out bits of the file I can reproduce the IndexError with just this:

importsyssys.ps1='\001\033[0;32m\002>>>\001\033[0m\002'delsys

The\001/\002 characters are hints for readline to inform it that everything between them is a terminal escape sequence that doesn't advance the cursor, without which readline cannot correctly compute the width of the prompt and makes wrong assumptions about line wrapping.

The IndexError goes away if I remove all\001 and\002 characters from sys.ps1.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixestopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp