excepthook experiments with IDLE and Friendly-traceback
André Roberge <[email protected]> Wed, 10 Feb 2021 11:33:20 -0400
| Newsgroups | gmane.comp.python.idle |
|---|---|
| Message-ID | <CAGMu_=rmx9Q9fkf=banNLHJv_XNSpBWC-4j3TKxSrPrpvG5-sQ@mail.gmail.com> |
--===============0833048499885587468==
Content-Type: multipart/alternative; boundary="0000000000009e291805bafd2174"
--0000000000009e291805bafd2174
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Hello everyone,
The latest Python version (3.10.a5) of IDLE's repl has support for
user-defined exception hooks. After being contacted by Terry Reedy about
this feature, I investigated integrating Friendly-traceback [1] with IDLE.
For those that are interested, I have documented on github [2] (with
screenshots) how Friendly-traceback works with IDLE, including some
limitations. Feel free to comment on that issue for any suggestion you
might have about possible improvements to Friendly-traceback, including the
current API used.
In some cases, I determine based on Python's version whether or not a
feature can be enabled. I consider this to be brittle. Rather than relying
on Python's version, I would much prefer if I could be able to write
something like:
try:
from idlelib import support_excepthook
except:
support_excepthook =3D False
This would be especially useful if this support for user-defined exception
hooks within IDLE's shell is backported to older versions of Python.
Something similar would also be useful if and when support for custom
handling of SyntaxError is added to IDLE.
Best,
Andr=C3=A9 Roberge
[1] https://aroberge.github.io/friendly-traceback-docs/docs/html/
Currently, the documentation does not include the new IDLE-related features=
.
[2] https://github.com/aroberge/friendly-traceback/issues/183
--0000000000009e291805bafd2174
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:arial,he=
lvetica,sans-serif;font-size:small">Hello everyone,</div><div class=3D"gmai=
l_default" style=3D"font-family:arial,helvetica,sans-serif;font-size:small"=
><br></div><div class=3D"gmail_default" style=3D"font-family:arial,helvetic=
a,sans-serif;font-size:small">The latest Python version (3.10.a5) of IDLE&#=
39;s repl has support for user-defined exception hooks. After being contact=
ed by Terry Reedy about this feature, I investigated integrating Friendly-t=
raceback [1] with IDLE.=C2=A0=C2=A0</div><div class=3D"gmail_default" style=
=3D"font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div =
class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif;fon=
t-size:small">For those that are interested, I have documented on=C2=A0gith=
ub=20
[2]
(with screenshots) how Friendly-traceback works with IDLE, including some l=
imitations. Feel free to comment on that issue for any suggestion you migh=
t have about possible improvements to Friendly-traceback, including the cur=
rent API used.</div><div class=3D"gmail_default" style=3D"font-family:arial=
,helvetica,sans-serif;font-size:small"><br></div><div class=3D"gmail_defaul=
t" style=3D"font-family:arial,helvetica,sans-serif;font-size:small">In some=
cases, I determine based on Python's version whether or not a feature =
can be enabled. I consider this to be brittle.=C2=A0 Rather than relying on=
Python's version, I would=C2=A0much prefer if I could be able to write=
something like:</div><div class=3D"gmail_default" style=3D"font-family:ari=
al,helvetica,sans-serif;font-size:small"><br></div><div class=3D"gmail_defa=
ult" style=3D"font-family:arial,helvetica,sans-serif;font-size:small">try:<=
/div><div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans=
-serif;font-size:small">=C2=A0 =C2=A0 from idlelib import support_excepthoo=
k</div><div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sa=
ns-serif;font-size:small">except:</div><div class=3D"gmail_default" style=
=3D"font-family:arial,helvetica,sans-serif;font-size:small">=C2=A0 =C2=A0 s=
upport_excepthook =3D False</div><div class=3D"gmail_default" style=3D"font=
-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class=3D=
"gmail_default" style=3D"font-family:arial,helvetica,sans-serif;font-size:s=
mall">This would=C2=A0be especially useful if this support for user-defined=
exception hooks within IDLE's shell is backported to older versions of=
Python.</div><div class=3D"gmail_default" style=3D"font-family:arial,helve=
tica,sans-serif;font-size:small"><br></div><div class=3D"gmail_default" sty=
le=3D"font-family:arial,helvetica,sans-serif;font-size:small">Something sim=
ilar would also be useful if and when support for custom handling of Syntax=
Error is added to IDLE.</div><div class=3D"gmail_default" style=3D"font-fam=
ily:arial,helvetica,sans-serif;font-size:small"><br></div><div class=3D"gma=
il_default" style=3D"font-family:arial,helvetica,sans-serif;font-size:small=
">Best,</div><div class=3D"gmail_default" style=3D"font-family:arial,helvet=
ica,sans-serif;font-size:small"><br></div><div class=3D"gmail_default" styl=
e=3D"font-family:arial,helvetica,sans-serif;font-size:small">Andr=C3=A9 Rob=
erge</div><div class=3D"gmail_default" style=3D"font-family:arial,helvetica=
,sans-serif;font-size:small"><br></div><div class=3D"gmail_default" style=
=3D"font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div =
class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif;fon=
t-size:small">[1]=C2=A0<a href=3D"https://aroberge.github.io/friendly-trace=
back-docs/docs/html/">https://aroberge.github.io/friendly-traceback-docs/do=
cs/html/</a>=C2=A0 Currently, the documentation does not include the new ID=
LE-related features.</div><div class=3D"gmail_default" style=3D"font-family=
:arial,helvetica,sans-serif;font-size:small">[2]=C2=A0<a href=3D"https://gi=
thub.com/aroberge/friendly-traceback/issues/183">https://github.com/aroberg=
e/friendly-traceback/issues/183</a></div></div>
--0000000000009e291805bafd2174--
--===============0833048499885587468==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
IDLE-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/idle-dev
--===============0833048499885587468==--