diff options
author | shadchin <shadchin@yandex-team.com> | 2024-08-17 21:51:59 +0300 |
---|---|---|
committer | shadchin <shadchin@yandex-team.com> | 2024-08-17 22:04:51 +0300 |
commit | ee9edbd8878888bafcd0eeb3b528f3ec4311560b (patch) | |
tree | d54d8138e50a446904f10a2092719be86af011b7 /contrib/tools/python3/Lib/code.py | |
parent | 72cbe4bad58add0912623ba51351ff1db8587249 (diff) | |
download | ydb-ee9edbd8878888bafcd0eeb3b528f3ec4311560b.tar.gz |
Update Python 3 to 3.12.5
https://docs.python.org/release/3.12.5/whatsnew/changelog.html#python-3-12-5-final
de86cdeacd3a8653b9ec36e87975886fafcf6dc2
Diffstat (limited to 'contrib/tools/python3/Lib/code.py')
-rw-r--r-- | contrib/tools/python3/Lib/code.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/contrib/tools/python3/Lib/code.py b/contrib/tools/python3/Lib/code.py index 2bd5fa3e79..b4b1ef3b8b 100644 --- a/contrib/tools/python3/Lib/code.py +++ b/contrib/tools/python3/Lib/code.py @@ -127,7 +127,7 @@ class InteractiveInterpreter: else: # If someone has set sys.excepthook, we let that take precedence # over self.write - sys.excepthook(type, value, tb) + self._call_excepthook(type, value, tb) def showtraceback(self): """Display the exception that just occurred. @@ -141,16 +141,29 @@ class InteractiveInterpreter: sys.last_traceback = last_tb sys.last_exc = ei[1] try: - lines = traceback.format_exception(ei[0], ei[1], last_tb.tb_next) if sys.excepthook is sys.__excepthook__: + lines = traceback.format_exception(ei[0], ei[1], last_tb.tb_next) self.write(''.join(lines)) else: # If someone has set sys.excepthook, we let that take precedence # over self.write - sys.excepthook(ei[0], ei[1], last_tb) + self._call_excepthook(ei[0], ei[1], last_tb) finally: last_tb = ei = None + def _call_excepthook(self, typ, value, tb): + try: + sys.excepthook(typ, value, tb) + except SystemExit: + raise + except BaseException as e: + e.__context__ = None + print('Error in sys.excepthook:', file=sys.stderr) + sys.__excepthook__(type(e), e, e.__traceback__.tb_next) + print(file=sys.stderr) + print('Original exception was:', file=sys.stderr) + sys.__excepthook__(typ, value, tb) + def write(self, data): """Write a string. |