Skip to content

New REPL exits when there are non-string candidates for suggestions#130999

@devdanzin

Description

@devdanzin

Crash report

What happened?

The new REPL in main will exit if a suggestion would be offered, but there are non-string candidates like below:

>>>importrunpy ... runpy._run_module_code("blech",{0: "", "bluch": ""}, "") ... Exceptionignoredintheinternaltracebackmachinery: Traceback (mostrecentcalllast): File"/home/danzin/projects/cpython/Lib/traceback.py", line139, in_print_exception_bltinreturnprint_exception(exc, limit=BUILTIN_EXCEPTION_LIMIT, file=file, colorize=colorize) File"/home/danzin/projects/cpython/Lib/traceback.py", line129, inprint_exceptionte=TracebackException(type(value), value, tb, limit=limit, compact=True) File"/home/danzin/projects/cpython/Lib/traceback.py", line1138, in__init__context=TracebackException( File"/home/danzin/projects/cpython/Lib/traceback.py", line1094, in__init__suggestion=_compute_suggestion_error(exc_value, exc_traceback, wrong_name) File"/home/danzin/projects/cpython/Lib/traceback.py", line1535, in_compute_suggestion_errorreturn_suggestions._generate_suggestions(d, wrong_name) TypeError: allelementsin'candidates'mustbestringsTraceback (mostrecentcalllast): File"<python-input-0>", line2, in<module>File"/home/danzin/projects/cpython/Lib/runpy.py", line98, in_run_module_code_run_code(code, mod_globals, init_globals, File"/home/danzin/projects/cpython/Lib/runpy.py", line88, in_run_codeexec(code, run_globals) File"<string>", line1, in<module>NameError: name'blech'isnotdefinedDuringhandlingoftheaboveexception, anotherexceptionoccurred: Traceback (mostrecentcalllast): File"/home/danzin/projects/cpython/Lib/_pyrepl/console.py", line173, in_excepthooklines=traceback.format_exception( File"/home/danzin/projects/cpython/Lib/traceback.py", line154, informat_exceptionte=TracebackException(type(value), value, tb, limit=limit, compact=True) File"/home/danzin/projects/cpython/Lib/traceback.py", line1094, in__init__suggestion=_compute_suggestion_error(exc_value, exc_traceback, wrong_name) File"/home/danzin/projects/cpython/Lib/traceback.py", line1535, in_compute_suggestion_errorreturn_suggestions._generate_suggestions(d, wrong_name) TypeError: allelementsin'candidates'mustbestringsDuringhandlingoftheaboveexception, anotherexceptionoccurred: Traceback (mostrecentcalllast): File"/home/danzin/projects/cpython/Lib/runpy.py", line198, in_run_module_as_mainreturn_run_code(code, main_globals, None, File"/home/danzin/projects/cpython/Lib/runpy.py", line88, in_run_codeexec(code, run_globals) File"/home/danzin/projects/cpython/Lib/_pyrepl/__main__.py", line6, in<module>__pyrepl_interactive_console() File"/home/danzin/projects/cpython/Lib/_pyrepl/main.py", line59, ininteractive_consolerun_multiline_interactive_console(console) File"/home/danzin/projects/cpython/Lib/_pyrepl/simple_interact.py", line152, inrun_multiline_interactive_consolemore=console.push(_strip_final_indent(statement), filename=input_name, _symbol="single") # type: ignore[call-arg]File"/home/danzin/projects/cpython/Lib/code.py", line324, inpushmore=self.runsource(source, filename, symbol=_symbol) File"/home/danzin/projects/cpython/Lib/_pyrepl/console.py", line231, inrunsourceresult=self.runcode(code) File"/home/danzin/projects/cpython/Lib/_pyrepl/console.py", line191, inruncodeself.showtraceback() File"/home/danzin/projects/cpython/Lib/code.py", line128, inshowtracebackself._showtraceback(typ, value, tb.tb_next, "") File"/home/danzin/projects/cpython/Lib/code.py", line144, in_showtracebackself._excepthook(typ, value, tb) File"/home/danzin/projects/cpython/Lib/_pyrepl/console.py", line179, in_excepthooklines=traceback.format_exception( File"/home/danzin/projects/cpython/Lib/traceback.py", line154, informat_exceptionte=TracebackException(type(value), value, tb, limit=limit, compact=True) File"/home/danzin/projects/cpython/Lib/traceback.py", line1138, in__init__context=TracebackException( File"/home/danzin/projects/cpython/Lib/traceback.py", line1094, in__init__suggestion=_compute_suggestion_error(exc_value, exc_traceback, wrong_name) File"/home/danzin/projects/cpython/Lib/traceback.py", line1535, in_compute_suggestion_errorreturn_suggestions._generate_suggestions(d, wrong_name) TypeError: allelementsin'candidates'mustbestrings

This is an offshoot of #129573, where code like above would abort in 3.12.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.14.0a5+ (heads/main:a3990df6121, Mar 9 2025, 00:02:58) [GCC 13.3.0]

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-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