[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-02-04 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

IDLE also caches shell input.  Off topic here, I sent Andre an email about how 
FT could access it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-02-03 Thread Andre Roberge


Andre Roberge  added the comment:

Terry: as per your earlier comment, I have tried to use Friendly-traceback with 
the latest version. While it does set the exception hook correctly, it is not 
useful. 

Friendly-traceback (FT) needs to have access to the code that was executed. 
FT's REPL caches the code (similarly to what IPython does, but not CPython) 
prior to execution so that it can retrieve it correctly, have access to the 
relevant execution frame, etc.  This is not possible when using IDLE's REPL. In 
fact, for some types of exceptions, when FT tries to get access to the code, it 
ends up triggering secondary exceptions.

However, using the method describe in FT's documentation (with relies on FT's 
own console) still works correctly.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-29 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset bf782b2636880dd634281f905ae43b8555450ee2 by Miss Islington (bot) 
in branch '3.9':
bpo-43008: Add 'Patch by Ken Hilton' (GH-24370) (#24374)
https://github.com/python/cpython/commit/bf782b2636880dd634281f905ae43b8555450ee2


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-29 Thread miss-islington


miss-islington  added the comment:


New changeset cf883827496d0fbe2c5fe39e4778cd7525f6f7bc by Miss Islington (bot) 
in branch '3.8':
bpo-43008: Add 'Patch by Ken Hilton' (GH-24370)
https://github.com/python/cpython/commit/cf883827496d0fbe2c5fe39e4778cd7525f6f7bc


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23196
pull_request: https://github.com/python/cpython/pull/24375

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-29 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 11d75ec807f05eff1148c049e38b808d11c23b8a by Terry Jan Reedy in 
branch 'master':
bpo-43008: Add 'Patch by Ken Hilton' (GH-24370)
https://github.com/python/cpython/commit/11d75ec807f05eff1148c049e38b808d11c23b8a


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23195
pull_request: https://github.com/python/cpython/pull/24374

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-29 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
pull_requests: +23194
pull_request: https://github.com/python/cpython/pull/24370

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I hope this is not your last contribution.  Another hint: if one uses issue 
12643 or #12643, then the tracker makes the link -- and strikes it out if 
closed.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-26 Thread Ken Hilton


Ken Hilton  added the comment:

Oops, gotcha. Thanks for doing the tests. I'm a Python contributor! :D

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Ken, for next time -- there is a separate News category for IDLE.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-26 Thread miss-islington


miss-islington  added the comment:


New changeset 6f0346d09f78180886982e070cc92425ada96144 by Miss Islington (bot) 
in branch '3.8':
bpo-43008: Make IDLE respect sys.excepthook (GH-24302)
https://github.com/python/cpython/commit/6f0346d09f78180886982e070cc92425ada96144


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-26 Thread miss-islington


miss-islington  added the comment:


New changeset 68102fb9987338a70d69a0162917866e5710458d by Miss Islington (bot) 
in branch '3.9':
bpo-43008: Make IDLE respect sys.excepthook (GH-24302)
https://github.com/python/cpython/commit/68102fb9987338a70d69a0162917866e5710458d


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-26 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23167
pull_request: https://github.com/python/cpython/pull/24347

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-26 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +23166
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/24346

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 7a34380ad76f5ad50d4175ceb2d5715b8cff by Ken in branch 
'master':
bpo-43008: Make IDLE respect sys.excepthook (GH-24302)
https://github.com/python/cpython/commit/7a34380ad76f5ad50d4175ceb2d5715b8cff


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-26 Thread Ken Hilton


Ken Hilton  added the comment:

CLA registers as signed now.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-23 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Ken, I read on another issue that an exception in an except suite is 
automatically linked to the caught exception, though the printed result may not 
be exactly the same.  Once your CLA is 'activated', I will experiment with the 
options.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-23 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Andre: with this patch, you could potentially add a function or submodule that 
would point sys.excepthook to a function that would print the exception and 
then interact before returning.  If this worked, one could add, for instance, 
'import friendly_traceback.idle' at the top of a file or at a Shell prompt and 
have friendly-traceback only activate when there is an exception.  So it would 
work in Shell.

I hope by 3.10 to have IDLE '>>>' prompts moved into a sidebar (instead of line 
numbers.  F-T prompts would be distinctly different.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-23 Thread Andre Roberge


Andre Roberge  added the comment:

Terry: I will put it on my todo list. 

Friendly-traceback can currently work (indirectly) with IDLE; see 
https://aroberge.github.io/friendly-traceback-docs/docs/html/editor.html

I am not sure what benefit this patch will yield when it comes to using 
Friendly-traceback with IDLE compared with what is currently possible.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-23 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Ken: I will probably work on tests, perhaps as a followup or parallel issue.  I 
will likely do a bit or refactoring to make testing easier.

I just looked at print_exception and discovered that the double traceback can 
likely by handled by properly setting exc.context for the 2nd exception.  But 
getting that right will be aided by having something that already works.

Possible manual test protocol in Shell

>>> import sys
>>> def egood(a,b,c): print('Exception traceback', file=sys.stderr)

>>> sys.excepthook = egood
>>> 1/0
# "Exception traceback"
>>> def ebad(a,b,c): z

>>> sys.excepthook = ebad
>>> 1/0
# Double traceback for ZeroDivisionError and NameError

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-23 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Andre: while I would like friendlier tracebacks available in IDLE without 3rd 
party installation, I doubt this will happen soon.  In the meanwhile, I see 
that you are working to polish Friendly Traceback with a friendly contest.  I 
presume FT uses sys.excepthook.  If so, this issue is opportune for supporting 
your package.  Feel free to test the minimal patch as is, or when fleshed out, 
and let us know how it works.

--
nosy: +aroberge

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-23 Thread Ken Hilton


Ken Hilton  added the comment:

Made requested changes, besides the tests. I didn't manage to figure out how to 
go about testing an excepthook in the first place, let alone a good or bad one. 
Hope that's not an issue.

--
Added file: https://bugs.python.org/file49758/bpo-43008.patch.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43008] IDLE ignores sys.excepthook in normal, subprocess mode

2021-01-23 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I looked at all 4 hooks.

sys.breakpointhook is invoked by breakpoint() in user code, so is not IDLE's 
concern at present.

sys.unraiseablehook is invoked by the interpreter when user code messes up 
badly, so is not IDLE's condern.  (And it is an expert feature that beginners 
should ignore.)

sys.displayhook is set to rpc.displayhook in run.py or, if started with -n no 
subprocess, pyshell.py.  IDLE executes user code with exec().  Shell entries 
are compiled in 'single' mode.  Exec invokes displayhook for expression 
statements so compiled.  In both normal and -n mode, displayhook exceptions are 
displayed  and processed as user code exceptions, with the last traceback line 
giving the bad line.

sys.excepthook is invoked by the interpreter for uncaught exceptions.
In IDLE's -n mode, sys.excepthook *is* invoked.  If it raises, both tracebacks 
are printed, separated by "\nDuring handling of the above exception, another 
exception occurred:\n".  This issue is about having the same effect in normal 
2-process mode.

Since, in the subprocess, IDLE catches all user exceptions for its custom 
handling, there are no uncaught user exceptions.  I believe your patch calls 
the user hook in the proper place, but an uncaught exception in sys.excepthook 
would be nasty.  Replace the call with something like

try:
sys.e...k(...)
except BaseException as e:
print_exception()
print("\nDuring handling of the above exception, another exception 
occurred:\n", file=sys.stderr)
self.usr_exc_info = sys.exc_info()
print_exception()

If possible, I want a unittest added in test_run.py.  (I am not sure exactly 
how as I don't think we have yet directly faked receipt of compiled user code.)

class Executive(unittest.TextCase):

def test_good_excepthook(self):

def test_bad_excepthook(self):


A blurb is needed (and always is for anything non-trivial).

In Doc/library/idle.rst, I want to insert " and reset display and exception 
handling" before the period ending the current Shell entry.

Restart Shell
  Restart the shell to clean the environment.

--
stage:  -> test needed
title: IDLE ignores sys.excepthook -> IDLE ignores sys.excepthook in normal, 
subprocess mode
versions:  -Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com