From d6a3cdccdadeeb82f15ea56413255b3860bacde1 Mon Sep 17 00:00:00 2001 From: Chris Patti Date: Tue, 20 May 2025 15:47:57 -0400 Subject: [PATCH 1/3] [3.13] gh-128066: Properly handle history file writes for RO fs on PyREPL (gh-134380) (cherry picked from commit c91ad5da9d92eac4718e4da8d53689c3cc24535e) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Chris Patti Co-authored-by: Ɓukasz Langa --- Lib/_pyrepl/simple_interact.py | 5 +++++ Lib/site.py | 8 +++++++- .../2025-05-20-14-41-50.gh-issue-128066.qzzGfv.rst | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-05-20-14-41-50.gh-issue-128066.qzzGfv.rst diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index e686526870e364..4cd0cdb9da113b 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -30,6 +30,11 @@ import os import sys import code +<<<<<<< HEAD +======= +import warnings +import errno +>>>>>>> c91ad5da9d9 (gh-128066: Properly handle history file writes for RO fs on PyREPL (gh-134380)) from .readline import _get_reader, multiline_input diff --git a/Lib/site.py b/Lib/site.py index 89a81c55cb63dd..95d3e394d6fdb6 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -75,6 +75,7 @@ import _sitebuiltins import io import stat +import errno # Prefixes for site-packages; add additional prefixes like /usr/local here PREFIXES = [sys.prefix, sys.exec_prefix] @@ -572,10 +573,15 @@ def register_readline(): def write_history(): try: readline_module.write_history_file(history) - except (FileNotFoundError, PermissionError): + except FileNotFoundError, PermissionError: # home directory does not exist or is not writable # https://bugs.python.org/issue19891 pass + except OSError: + if errno.EROFS: + pass # gh-128066: read-only file system + else: + raise atexit.register(write_history) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-05-20-14-41-50.gh-issue-128066.qzzGfv.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-05-20-14-41-50.gh-issue-128066.qzzGfv.rst new file mode 100644 index 00000000000000..f78190276851b4 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-05-20-14-41-50.gh-issue-128066.qzzGfv.rst @@ -0,0 +1,3 @@ +Fixes an edge case where PyREPL improperly threw an error when Python is +invoked on a read only filesystem while trying to write history file +entries. From 46f03900496d405c8958c4b9c9637710455c21be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Tue, 20 May 2025 21:50:41 +0200 Subject: [PATCH 2/3] Fix botched merge --- Lib/_pyrepl/simple_interact.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index 4cd0cdb9da113b..e686526870e364 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -30,11 +30,6 @@ import os import sys import code -<<<<<<< HEAD -======= -import warnings -import errno ->>>>>>> c91ad5da9d9 (gh-128066: Properly handle history file writes for RO fs on PyREPL (gh-134380)) from .readline import _get_reader, multiline_input From 54462ed4d5d00a33c19bc0a28a97a6f755b53805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Tue, 20 May 2025 21:51:20 +0200 Subject: [PATCH 3/3] Parens around exceptions needed in 3.13 --- Lib/site.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/site.py b/Lib/site.py index 95d3e394d6fdb6..aedf36399c37ad 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -573,7 +573,7 @@ def register_readline(): def write_history(): try: readline_module.write_history_file(history) - except FileNotFoundError, PermissionError: + except (FileNotFoundError, PermissionError): # home directory does not exist or is not writable # https://bugs.python.org/issue19891 pass pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy