Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c91ad5d

Browse filesBrowse files
feohambv
andauthored
gh-128066: Properly handle history file writes for RO fs on PyREPL (gh-134380)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent c7f8e70 commit c91ad5d
Copy full SHA for c91ad5d

File tree

Expand file treeCollapse file tree

3 files changed

+12
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-1
lines changed

‎Lib/_pyrepl/simple_interact.py

Copy file name to clipboardExpand all lines: Lib/_pyrepl/simple_interact.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import sys
3232
import code
3333
import warnings
34+
import errno
3435

3536
from .readline import _get_reader, multiline_input, append_history_file
3637

@@ -153,6 +154,7 @@ def maybe_run_command(statement: str) -> bool:
153154
append_history_file()
154155
except (FileNotFoundError, PermissionError, OSError) as e:
155156
warnings.warn(f"failed to open the history file for writing: {e}")
157+
156158
input_n += 1
157159
except KeyboardInterrupt:
158160
r = _get_reader()

‎Lib/site.py

Copy file name to clipboardExpand all lines: Lib/site.py
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import _sitebuiltins
7676
import _io as 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]
@@ -578,10 +579,15 @@ def register_readline():
578579
def write_history():
579580
try:
580581
readline_module.write_history_file(history)
581-
except (FileNotFoundError, PermissionError):
582+
except FileNotFoundError, PermissionError:
582583
# home directory does not exist or is not writable
583584
# https://bugs.python.org/issue19891
584585
pass
586+
except OSError:
587+
if errno.EROFS:
588+
pass # gh-128066: read-only file system
589+
else:
590+
raise
585591

586592
atexit.register(write_history)
587593

+3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.