From 5a8e1373fe5700ca52b55117880b32912fbece3a Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:10:13 +0200 Subject: [3.13] gh-78889: Stop IDLE Shell freezes from sys.stdout.shell.xyz (GH-121876) (#121911) gh-78889: Stop IDLE Shell freezes from sys.stdout.shell.xyz (GH-121876) 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. (cherry picked from commit 58753f33e47fe48906883dc010771f68c13b7e52) Co-authored-by: Terry Jan Reedy --- Lib/idlelib/News3.txt | 3 +++ Lib/idlelib/run.py | 3 +++ Misc/NEWS.d/next/IDLE/2024-07-16-16-57-03.gh-issue-78889.U7ghFD.rst | 2 ++ 3 files changed, 8 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 b1b652d..68702ac 100644 --- a/Lib/idlelib/News3.txt +++ b/Lib/idlelib/News3.txt @@ -4,6 +4,9 @@ Released on 2024-10-xx ========================= +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. 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 8974b52..8f98e73 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 0000000..604194e --- /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 non-method sys.stdout.shell attributes, +which are all private. -- cgit v0.12