[issue43148] Call sys.unraisablehook in the REPL when sys.excepthook is broken
Julian Berman
report at bugs.python.org
Sat Feb 6 15:55:56 EST 2021
New submission from Julian Berman <Julian+Python.org at GrayVines.com>:
At the REPL, when sys.excepthook is broken (below by setting it to a non-callable), one sees:
```
⊙ python3.9 julian at Airm
Python 3.9.1 (default, Feb 2 2021, 22:54:59)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; sys.excepthook = object(); asdf
Error in sys.excepthook:
TypeError: 'object' object is not callable
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'asdf' is not defined
```
The implementation (https://github.com/python/cpython/blob/5f18c223391eef8c7d01241b51a7b2429609dd84/Python/pythonrun.c#L805-L817) seems to do so by reimplementing something like 3.8+'s sys.unraisablehook (well, technically it predates sys.unraisablehook by quite a while).
Seems like now that it exists, that code should now call sys.unraisablehook.
----------
messages: 386569
nosy: Julian, vstinner
priority: normal
severity: normal
status: open
title: Call sys.unraisablehook in the REPL when sys.excepthook is broken
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43148>
_______________________________________
More information about the Python-bugs-list
mailing list