[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2022-01-15 Thread Terry J. Reedy
Terry J. Reedy added the comment: Whatever you worked out is probably better than depending on something that I hope to significantly change. -- resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2022-01-14 Thread Andre Roberge
Andre Roberge added the comment: As far as I am concerned, this issue can be closed. I have found a workaround which allows me to reproduce and analyze the SyntaxError that are not captured by custom exception hook. -- ___ Python tracker

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2021-06-28 Thread Andre Roberge
Andre Roberge added the comment: I made an error in my previous comment: the code I wrote is obviously incorrect as it contains a SyntaxError. -- ___ Python tracker ___ _

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2021-06-22 Thread Andre Roberge
Andre Roberge added the comment: I can confirm that, if the existing line type, value, tb = sys.exc_info() in pyshell.ModifiedInterpreter.showsyntaxerror is replaced by e_type, value, tb = sys.exc_info() err = str((type(e_type).__name__, *value)+'\n' linecache.cache[""] = (len(err), 0, [err]

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2021-06-21 Thread Andre Roberge
Andre Roberge added the comment: Unless I am mistaken, when compiling the code, both SyntaxError and OverflowError instances are caught at the same stage, and likely passed on to showsyntaxerror. For OverflowError, e.args is not normally a tuple but a string, and *e.args[1] would raise an e

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2021-06-21 Thread Andre Roberge
Andre Roberge added the comment: Having a fake file with a single line containing all the exception information as described would definitely provide all the required information needed. It would be much better than what I had suggested previously. -- ___

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2021-06-20 Thread Terry J. Reedy
Terry J. Reedy added the comment: What I am proposing that pseudofile have one line representing a tuple with all the exception information, *including the filename* for the code with the error. In Shell, the filename will usually be another pseudofile name, . The latter are set with

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2021-06-20 Thread Andre Roberge
Andre Roberge added the comment: I just thought of making a copy of the file content under a known name as the least disruptive approach for IDLE's code - even less so than the recent addition required to support user-defined exception hooks. For SyntaxErrors and subclasses [1], Friendly nee

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2021-06-19 Thread Terry J. Reedy
Terry J. Reedy added the comment: The comment should be "# For 3rd party use. See issue 43476." Updates to the pypi url, now https://pypi.org/project/friendly/ should be recorded here on this issue. The undocumented name 'cache' is excluded from linecache.__all__ and therefore private. We

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2021-06-19 Thread Andre Roberge
Andre Roberge added the comment: Would it be possible to add a single line of code to idlelib's pyshell.py, as indicated below: def showsyntaxerror(self, filename=None): """... """ linecache.cache[""] = linecache.cache[filename] # here tkconsole = self.tkconsole ... Of cours

[issue43476] Enabling access to showsyntaxerror for IDLE's shell

2021-03-11 Thread Andre Roberge
New submission from Andre Roberge : As a result of https://bugs.python.org/issue43008, IDLE now supports custom exception hook for almost all cases except for code entered in the interactive shell that result in SyntaxError. It would be useful for some applications if a way to replace the err