]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-128066: Properly handle history file writes for RO fs on PyREPL (gh-134380...
authorŁukasz Langa <lukasz@langa.pl>
Tue, 20 May 2025 20:15:43 +0000 (22:15 +0200)
committerGitHub <noreply@github.com>
Tue, 20 May 2025 20:15:43 +0000 (22:15 +0200)
(cherry picked from commit c91ad5da9d92eac4718e4da8d53689c3cc24535e)

Co-authored-by: Chris Patti <feoh@feoh.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Lib/site.py
Misc/NEWS.d/next/Core_and_Builtins/2025-05-20-14-41-50.gh-issue-128066.qzzGfv.rst [new file with mode: 0644]

index 89a81c55cb63dd5b9cc174706a252344b698a5ec..aedf36399c37ad8a7a2c404cd971454d1ede5b61 100644 (file)
@@ -75,6 +75,7 @@ import builtins
 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]
@@ -576,6 +577,11 @@ def register_readline():
                 # 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 (file)
index 0000000..f781902
--- /dev/null
@@ -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.