From taleinat at gmail.com Sun Jun 6 04:04:07 2021 From: taleinat at gmail.com (Tal Einat) Date: Sun, 6 Jun 2021 11:04:07 +0300 Subject: [Idle-dev] Does anyone rebind <>, <> or <>? Message-ID: Hi, I'm working on fixing an annoying IDLE bug whereby tab-completion stops working after any use of the config dialog. https://bugs.python.org/issue43654 The proposed fix removes the ability to rebind the following three pseudo-events, which have the following default key bindings: '<>': [''] '<>': ['', ''] '<>': [''] Will removing the ability to change these bindings matter to anyone? - Tal Einat -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at markroseman.com Fri Jun 11 12:56:26 2021 From: mark at markroseman.com (Mark Roseman) Date: Fri, 11 Jun 2021 09:56:26 -0700 Subject: [Idle-dev] config dialog Message-ID: <72D91737-827C-48F6-B372-537FB5502478@markroseman.com> Terry, new changes are a definite improvement - keep up the great work! Mark From andre.roberge at gmail.com Sat Jun 19 17:36:56 2021 From: andre.roberge at gmail.com (=?UTF-8?Q?Andr=C3=A9_Roberge?=) Date: Sat, 19 Jun 2021 18:36:56 -0300 Subject: [Idle-dev] Complete user-defined exception handling in IDLE Message-ID: Hi everyone, With the latest Python beta version (3.10.0), IDLE's shell now supports custom exception hooks. (https://docs.python.org/3.10/whatsnew/3.10.html#idle-and-idlelib) However, this support is incomplete since when SyntaxErrors are raised for code entered in IDLE's shell, the information is not passed to custom exception hooks. A while ago, I filed an issue https://bugs.python.org/issue43476 suggesting that it would be "nice" to make this possible. I tried on my own, but have not been able to figure out how to do it. However, as noted in the issue, I found a workaround of sorts: adding a single line of code to save the offending code into a specially named file. This file can then be accessed like any others allowing someone to recreate the SyntaxError and handle it as desired. For those that are curious to see what it may look like, I suggest you install "friendly" from PyPI, and add the one line to your Python 3.10 idlelib.pyshell.py file as mentioned in the issue linked above. This is a sample session illustrating what it looks like [it's more impressive with colours, of course! ;-) ] ========================================== >>> from friendly.idle import * >>> install() WARNING Friendly cannot handle SyntaxErrors for code entered in the shell. >>> from math import pi >>> tau = 2pi SyntaxError: invalid decimal literal >>> explain("syntax") # Special friendly command needed to recreate the exception File "", line 1 tau = 2pi ^ SyntaxError: invalid decimal literal Perhaps you forgot a multiplication operator, 2 * pi. >>> why() Valid names cannot begin with a number. Perhaps you forgot a multiplication operator, 2 * pi. >>> what() A SyntaxError occurs when Python cannot understand your code. >>> where() Python could not understand the code in the file '' beyond the location indicated by ^. -->1: tau = 2pi ^ ===================== You can also simply type "Friendly" at a prompt, and a special __repr__ will provide some quick help. (This is not yet documented.) And, of course, Friendly makes uses of the new support for custom exception hook for runtime errors. It is possible that I will change explain("syntax") to explain("SyntaxError") in a future version - depending on feedback and assuming there is some support for a change in IDLE's code as described. If any of you try it out, I'd be really curious to see what you think of this. More information about friendly and IDLE can be found at https://aroberge.github.io/friendly-traceback-docs/docs/html/idle_repl.html Cheers, Andr? Roberge -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Sat Jun 19 22:36:14 2021 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 19 Jun 2021 22:36:14 -0400 Subject: [Idle-dev] Complete user-defined exception handling in IDLE In-Reply-To: References: Message-ID: <0a203360-c142-634e-133b-4da8a6189474@udel.edu> On 6/19/2021 5:36 PM, Andr? Roberge wrote: > Hi everyone, > > With the latest Python beta version (3.10.0), IDLE's shell now supports > custom exception hooks. > (https://docs.python.org/3.10/whatsnew/3.10.html#idle-and-idlelib > ) > However, this support is incomplete since when SyntaxErrors are raised > for code entered in IDLE's shell, the information is not passed to > custom exception hooks. > > A while ago, I filed an issue https://bugs.python.org/issue43476 > suggesting that it would be "nice" > to make this possible.? I tried on my own, but have not been able to > figure out how to do it.? However, as noted in the issue, I found a > workaround of sorts: adding a single line of code to save the offending > code into a specially named file.? This file can then be accessed like > any others allowing someone to recreate the SyntaxError and handle it as > desired. I gave more feedback on the issue. IDLE already has a bit of code for a 3rd party package, V-IDLE?, which I am not sure is still current. > For those that are curious to see what it may look like, I suggest you > install "friendly" from PyPI, and add the one line to your Python 3.10 > idlelib.pyshell.py file as mentioned in the > issue linked above.? This is a sample session illustrating what it looks > like [it's more impressive with colours, of course! ;-) ] > > ========================================== > > >>> from friendly.idle import * I hope you document the alternative for anyone wanting to isolate f.i functions: `import friendly.idle as fi` or `from friendly import idle as fi`. In any case, fi executes in the user process. Do you use the rpc connection to query linecache in the IDLE process? > >>> install() > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? WARNING > Friendly cannot handle SyntaxErrors for code entered in the shell. > >>> from math import pi > >>> tau = 2pi > SyntaxError: invalid decimal literal > >>> explain("syntax") ?# Special friendly command needed to recreate > the exception On the issue, I suggested de-serializing the original rather than recompiling. > ? File "", line 1 > ? ? tau = 2pi > ? ? ? ? ? ^ > SyntaxError: invalid decimal literal > > ? ? ? ? Perhaps you forgot a multiplication operator, 2 * pi. > >>> why() > > ? ? Valid names cannot begin with a number. > ? ? Perhaps you forgot a multiplication operator, 2 * pi. > >>> what() > > ? ? A SyntaxError occurs when Python cannot understand your code. > >>> where() > > ? ? Python could not understand the code in the file > ? ? '' > ? ? beyond the location indicated by ^. > > ? ? -->1: tau = 2pi > ? ? ? ? ? ? ? ? ^ > > ===================== > You can also simply type "Friendly" at a prompt, and a special __repr__ > will provide some quick help.? (This is not yet documented.)? And, of > course, Friendly makes uses of the new support for custom exception hook > for runtime errors. > > It is possible that I will change explain("syntax") to > explain("SyntaxError") in a future version - depending on feedback and > assuming there is some support for a change in IDLE's code as described. I think it is fine as is. > If any of you try it out, I'd be really curious to see what you think of > this. > > More information about friendly and IDLE can be found at > https://aroberge.github.io/friendly-traceback-docs/docs/html/idle_repl.html > From andre.roberge at gmail.com Sun Jun 20 05:13:29 2021 From: andre.roberge at gmail.com (=?UTF-8?Q?Andr=C3=A9_Roberge?=) Date: Sun, 20 Jun 2021 06:13:29 -0300 Subject: [Idle-dev] Complete user-defined exception handling in IDLE In-Reply-To: <0a203360-c142-634e-133b-4da8a6189474@udel.edu> References: <0a203360-c142-634e-133b-4da8a6189474@udel.edu> Message-ID: On Sat, Jun 19, 2021 at 11:36 PM Terry Reedy wrote: > On 6/19/2021 5:36 PM, Andr? Roberge wrote: > > > >>> from friendly.idle import * > > I hope you document the alternative for anyone wanting to isolate f.i > functions: `import friendly.idle as fi` or > `from friendly import idle as fi`. > > Documenting this is on my list of things to do. I already have had similar feedback from another instructor who uses it with the Jupyter module. The reason I usually write "import *" is that I view the functions why(), what(), where(), etc., like they are additional builtins available in an interactive session. (They are not added to the builtins module.) > In any case, fi executes in the user process. Do you use the rpc > connection to query linecache in the IDLE process? > Yes, I do. > > > On the issue, I suggested de-serializing the original rather than > recompiling. > It would make sense, if I knew how to access the information using rpc. For SyntaxErrors and subclasses, all I need for the analysis are the Exception argument (message, offset, lineno, etc.) and the entire offending code. Andr? -------------- next part -------------- An HTML attachment was scrubbed... URL: