From c6d6df4563422ceb4a9828a8bcd8900c10ebae52 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Tue, 16 Jul 2024 17:04:00 -0400 Subject: [PATCH 1/3] gh-78889: Stop IDLE Shell freezes from sys.stdout.shell.xyz Problem occurred when attribute xyz could not be pickled. Since this is not trivial to selectively fix, block all attributes (other than 'width'). IDLE does not access them and they are private implementation details. --- Lib/idlelib/News3.txt | 2 ++ Lib/idlelib/run.py | 3 +++ .../next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst diff --git a/Lib/idlelib/News3.txt b/Lib/idlelib/News3.txt index b1b652dc562c8e..d0930a9407bc01 100644 --- a/Lib/idlelib/News3.txt +++ b/Lib/idlelib/News3.txt @@ -4,6 +4,8 @@ Released on 2024-10-xx ========================= +gh-78889: Stop Shell freezes by blocking user access to sys.stdout.shell attributes, which are all private. + gh-78955: Use user-selected color theme for Help => IDLE Doc. gh-96905: In idlelib code, stop redefining built-ins 'dict' and 'object'. diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 8974b52674fb8c..8f98e73258e778 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -443,6 +443,9 @@ class StdioFile(io.TextIOBase): def __init__(self, shell, tags, encoding='utf-8', errors='strict'): self.shell = shell + # GH-78889: accessing unpickleable attributes freezes Shell. + # IDLE only needs methods; allow 'width' for possible use. + self.shell._RPCProxy__attributes = {'width': 1} self.tags = tags self._encoding = encoding self._errors = errors diff --git a/Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst b/Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst new file mode 100644 index 00000000000000..167ce9ce41e5b8 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst @@ -0,0 +1,2 @@ +Stop Shell freezes by blocking user access to sys.stdout.shell attributes, +which are all private. From 4e972893b6bec7b67f5ed451f01af46940cd3a49 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Tue, 16 Jul 2024 17:08:07 -0400 Subject: [PATCH 2/3] Update Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst --- .../next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst b/Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst index 167ce9ce41e5b8..604194ebb2e859 100644 --- a/Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst +++ b/Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst @@ -1,2 +1,2 @@ -Stop Shell freezes by blocking user access to sys.stdout.shell attributes, +Stop Shell freezes by blocking user access to non-method sys.stdout.shell attributes, which are all private. From 5075501fb154c24436930f780fe9d392bc166cff Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Tue, 16 Jul 2024 17:10:57 -0400 Subject: [PATCH 3/3] Update Lib/idlelib/News3.txt --- Lib/idlelib/News3.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/idlelib/News3.txt b/Lib/idlelib/News3.txt index d0930a9407bc01..68702ac8fb9157 100644 --- a/Lib/idlelib/News3.txt +++ b/Lib/idlelib/News3.txt @@ -4,7 +4,8 @@ Released on 2024-10-xx ========================= -gh-78889: Stop Shell freezes by blocking user access to sys.stdout.shell attributes, which are all private. +gh-78889: Stop Shell freezes by blocking user access to non-method +sys.stdout.shell attributes, which are all private. gh-78955: Use user-selected color theme for Help => IDLE Doc.