This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author andrewjcg
Recipients andrewjcg
Date 2012-10-04.23:52:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1349394780.28.0.923022645672.issue16139@psf.upfronthosting.co.za>
In-reply-to
Content
This occurs when python is installed on a read-only mount AND all the .pyc files are out-of-date.  Therefore, when python starts and attempts to write a new .pyc file, _write_atomic in "Lib/importlib/_bootstrap.py" throws an OSError with an errno of EROFS, which is not handled (and ignored) and kills the interpreter.

$ python
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 854, in _load_module
  File "<frozen importlib._bootstrap>", line 990, in get_code
  File "<frozen importlib._bootstrap>", line 1051, in _cache_bytecode
  File "<frozen importlib._bootstrap>", line 1074, in set_data
  File "<frozen importlib._bootstrap>", line 128, in _write_atomic
OSError: [Errno 30] Read-only file system: '<read-only-mount-path>/lib/python3.3/encodings/__pycache__/__init__.cpython-33.pyc.139872939267056'
Aborted (core dumped)

The following (hacky) patch fixes the issue for me:

--- a/Python-3.Lib/importlib/_bootstrap.py
+++ b/Python-3.Lib/importlib/_bootstrap.py
@@ -1070,6 +1070,10 @@ class SourceFileLoader(FileLoader, SourceLoader):
                 # If can't get proper access, then just forget about writing
                 # the data.
                 return
+            except OSError as e:
+                if e.errno != 30:  # ignore EROFS
+                    raise
+                return
         try:
             _write_atomic(path, data, _mode)
             _verbose_message('created {!r}', path)
@@ -1077,6 +1081,9 @@ class SourceFileLoader(FileLoader, SourceLoader):
             # Don't worry if you can't write bytecode or someone is writing
             # it at the same time.
             pass
+        except OSError as e:
+            if e.errno != 30:  # ignore EROFS
+                raise
History
Date User Action Args
2012-10-04 23:53:00andrewjcgsetrecipients: + andrewjcg
2012-10-04 23:53:00andrewjcgsetmessageid: <1349394780.28.0.923022645672.issue16139@psf.upfronthosting.co.za>
2012-10-04 23:53:00andrewjcglinkissue16139 messages
2012-10-04 23:52:59andrewjcgcreate