From 3d916a7b1ee29896bece4a6a37d8084fa3c1abf6 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 16 Sep 2019 23:24:02 -0700 Subject: [PATCH] bpo-35379: When exiting IDLE, catch any AttributeError. (GH-16212) One happens when EditorWindow.close is called twice. Printing a traceback, when IDLE is run from a terminal, is useless and annoying. (cherry picked from commit dfd34a9cd58e8150c324190f746de919e140abe8) Co-authored-by: Terry Jan Reedy --- Lib/idlelib/NEWS.txt | 7 +++++++ Lib/idlelib/editor.py | 11 +++++++---- .../IDLE/2019-09-17-01-28-56.bpo-35379.yAECDr.rst | 3 +++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/IDLE/2019-09-17-01-28-56.bpo-35379.yAECDr.rst diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index da2512913f0e..32fda8c75bb8 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -2,6 +2,13 @@ What's New in IDLE 3.7.5 Released on 2019-09-30? ====================================== +bpo-35379: When exiting IDLE, catch any AttributeError. One happens +when EditorWindow.close is called twice. Printing a traceback, when +IDLE is run from a terminal, is useless and annoying. + +bpo-38183: To avoid test issues, test_idle ignores the user config +directory. It no longer tries to create or access .idlerc or any files +within. Users must run IDLE to discover problems with saving settings. bpo-38077: IDLE no longer adds 'argv' to the user namespace when initializing it. This bug only affected 3.7.4 and 3.8.0b2 to 3.8.0b4. diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 838cb04b8008..b969f8c493b2 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1061,10 +1061,13 @@ class EditorWindow(object): return self.io.maybesave() def close(self): - reply = self.maybesave() - if str(reply) != "cancel": - self._close() - return reply + try: + reply = self.maybesave() + if str(reply) != "cancel": + self._close() + return reply + except AttributeError: # bpo-35379: close called twice + pass def _close(self): if self.io.filename: diff --git a/Misc/NEWS.d/next/IDLE/2019-09-17-01-28-56.bpo-35379.yAECDr.rst b/Misc/NEWS.d/next/IDLE/2019-09-17-01-28-56.bpo-35379.yAECDr.rst new file mode 100644 index 000000000000..98d41674b65d --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2019-09-17-01-28-56.bpo-35379.yAECDr.rst @@ -0,0 +1,3 @@ +When exiting IDLE, catch any AttributeError. One happens when +EditorWindow.close is called twice. Printing a traceback, when IDLE is run +from a terminal, is useless and annoying. -- 2.47.3