-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-102778: IDLE - make sys.last_exc available in Shell after traceback #103314
Conversation
Is this documented anywhere in idlelib docs? |
Yes and no. The 'yes' part is that "Running user code" says that IDLE generally tries to run user code so that it gives the same output (objects) one would get if one runs the same code in python itself, in either batch or interactive mode. Some known differences are then listed in this section and the next, "Displaying output in Shell". For this issue, user-code sys.last_xyz expressions should have the same result as with python.exe in the same circumstances. In user code, In 3.12, last_exc must be set after the the first uncaught-by-user-code 'interactive' exception. Since IDLE intends to simulate running code from an editor with The immediate manual test is that IDLE imitate the REPL as below instead of raising AttributeError as it does now.
Fixing test_run to check this may or may not be simple. This change should get a line in What's New 3.12. Check the IDLE entry in What's New 3.11. This could be done later. The no part is that the rest of the patch, including that to pyshell.py, only concerns stackviewer. This is internal code of no direct concern to users. It need not be done now, or even in 3.12, as it should continue to work. When revised, the support for 2.x string exceptions and the use of the old attributes (which were for support of string exceptions) should be removed. The only effect on users would be that the way to disable stackviewer will change from |
Reviewing further, I think that the second In any case, I would like to be able to pass the exception object to stackviewer and its tree item so that the module has no need of sys. Such a change could be attached to #102832 and backported to 3.11. #68978 has a list of possible improvements for stackviewer and if I get familiar with the code again I might want to do some and backport to 3.11. Closing was an accident. Time to sleep. |
I verified that the setting of sys.last_exc in print_exception should be sufficient. |
* main: (24 commits) pythongh-98040: Move the Single-Phase Init Tests Out of test_imp (pythongh-102561) pythongh-83861: Fix datetime.astimezone() method (pythonGH-101545) pythongh-102856: Clean some of the PEP 701 tokenizer implementation (python#103634) pythongh-102856: Skip test_mismatched_parens in WASI builds (python#103633) pythongh-102856: Initial implementation of PEP 701 (python#102855) pythongh-103583: Add ref. dependency between multibytecodec modules (python#103589) pythongh-83004: Harden msvcrt further (python#103420) pythonGH-88342: clarify that `asyncio.as_completed` accepts generators yielding tasks (python#103626) pythongh-102778: IDLE - make sys.last_exc available in Shell after traceback (python#103314) pythongh-103582: Remove last references to `argparse.REMAINDER` from docs (python#103586) pythongh-103583: Always pass multibyte codec structs as const (python#103588) pythongh-103617: Fix compiler warning in _iomodule.c (python#103618) pythongh-103596: [Enum] do not shadow mixed-in methods/attributes (pythonGH-103600) pythonGH-100530: Change the error message for non-class class patterns (pythonGH-103576) pythongh-95299: Remove lingering setuptools reference in installer scripts (pythonGH-103613) [Doc] Fix a typo in optparse.rst (python#103504) pythongh-101100: Fix broken reference `__format__` in `string.rst` (python#103531) pythongh-95299: Stop installing setuptools as a part of ensurepip and venv (python#101039) pythonGH-103484: Docs: add linkcheck allowed redirects entries for most cases (python#103569) pythongh-67230: update whatsnew note for csv changes (python#103598) ...
Fixes #102778.