python / python/cpython

"raise SyntaxError(NotImplemented)" exits REPL and IDLE subprocess

Offen
#152,490 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@terryjreedy arbeitet bereits daran.

Seit 28.6.2026.

stdlib topic-repl type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Bug report

Bug description:

Since Python 3.14, using NotImplemented in a boolean context started to raise TypeError.
Due to this change, raising SyntaxError (or its subclasses) with argument NotImplemented causes TypeError exception chaining and forces restarting the IDLE Shell. It's not reproducible for other exception types.

MRE:

raise SyntaxError(NotImplemented)

Traceback:

Traceback (most recent call last):
  File "C:/Users/benja/AppData/Local/Programs/Python/Python314/example.py", line 1, in <module>
    raise SyntaxError(NotImplemented)
Traceback (most recent call last):
  File "C:/Users/benja/AppData/Local/Programs/Python/Python314/example.py", line 1, in <module>
    raise SyntaxError(NotImplemented)
Traceback (most recent call last):
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 590, in runcode
    exec(code, self.locals)
    ~~~~^^^^^^^^^^^^^^^^^^^
  File "C:/Users/benja/AppData/Local/Programs/Python/Python314/example.py", line 1, in <module>
    raise SyntaxError(NotImplemented)
Traceback (most recent call last):
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 590, in runcode
    exec(code, self.locals)
    ~~~~^^^^^^^^^^^^^^^^^^^
  File "C:/Users/benja/AppData/Local/Programs/Python/Python314/example.py", line 1, in <module>
    raise SyntaxError(NotImplemented)
Traceback (most recent call last):
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 590, in runcode
    exec(code, self.locals)
  File "C:/Users/benja/AppData/Local/Programs/Python/Python314/example.py", line 1, in <module>
    raise SyntaxError(NotImplemented)
  File "<string>", line 0
SyntaxError: NotImplemented

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 172, in main
    ret = method(*args, **kwargs)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 604, in runcode
    print_exception()
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 278, in print_exception
    print_exc(typ, val, tb)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 274, in print_exc
    lines = get_message_lines(typ, exc, tb)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 240, in get_message_lines
    return traceback.format_exception_only(typ, exc)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 181, in format_exception_only
    return list(te.format_exception_only(show_group=show_group, colorize=colorize))
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 1263, in format_exception_only
    yield from [indent + l for l in self._format_syntax_error(stype, colorize=colorize)]
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 1456, in _format_syntax_error
    msg = self.msg or "<no detail available>"
TypeError: NotImplemented should not be used in a boolean context

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 186, in main
    print_exception()
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 278, in print_exception
    print_exc(typ, val, tb)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 264, in print_exc
    print_exc(type(context), context, context.__traceback__)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 274, in print_exc
    lines = get_message_lines(typ, exc, tb)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 240, in get_message_lines
    return traceback.format_exception_only(typ, exc)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 181, in format_exception_only
    return list(te.format_exception_only(show_group=show_group, colorize=colorize))
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 1263, in format_exception_only
    yield from [indent + l for l in self._format_syntax_error(stype, colorize=colorize)]
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 1456, in _format_syntax_error
    msg = self.msg or "<no detail available>"
TypeError: NotImplemented should not be used in a boolean context

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\idlelib\run.py", line 190, in main
    traceback.print_exception(type, value, tb, file=sys.__stderr__)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 134, in print_exception
    te.print(file=file, chain=chain, colorize=colorize)
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 1573, in print
    for line in self.format(chain=chain, colorize=colorize):
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 1510, in format
    yield from _ctx.emit(exc.format_exception_only(colorize=colorize))
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 999, in emit
    for text in text_gen:
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 1263, in format_exception_only
    yield from [indent + l for l in self._format_syntax_error(stype, colorize=colorize)]
  File "C:\Users\benja\AppData\Local\Programs\Python\Python314\Lib\traceback.py", line 1456, in _format_syntax_error
    msg = self.msg or "<no detail available>"
TypeError: NotImplemented should not be used in a boolean context

================================ RESTART: Shell ================================

So, I suggest changing the part of traceback.py code,

msg = self.msg or "<no detail available>"

to like this:

if self.msg is None:
    msg = "<no detail available>"
else:
    msg = self.msg
CPython versions tested on:

3.14, 3.15

Operating systems tested on:

Windows

Linked PRs
  • gh-152495

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.