Skip to content

Commit b41e7b1

Browse files
ambvfeoh
andauthored
[3.13] gh-128066: Properly handle history file writes for RO fs on PyREPL (gh-134380) (gh-134386)
(cherry picked from commit c91ad5d) Co-authored-by: Chris Patti <feoh@feoh.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent 7df6749 commit b41e7b1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Lib/site.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import _sitebuiltins
7676
import io
7777
import stat
78+
import errno
7879

7980
# Prefixes for site-packages; add additional prefixes like /usr/local here
8081
PREFIXES = [sys.prefix, sys.exec_prefix]
@@ -576,6 +577,11 @@ def write_history():
576577
# home directory does not exist or is not writable
577578
# https://bugs.python.org/issue19891
578579
pass
580+
except OSError:
581+
if errno.EROFS:
582+
pass # gh-128066: read-only file system
583+
else:
584+
raise
579585

580586
atexit.register(write_history)
581587

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fixes an edge case where PyREPL improperly threw an error when Python is
2+
invoked on a read only filesystem while trying to write history file
3+
entries.

0 commit comments

Comments
 (0)