[pypy-commit] pypy default: Wrap the I/O errors we can get when importing modules (one more place)

arigo pypy.commits at gmail.com
Fri Aug 9 09:37:34 EDT 2019


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r97119:1f0f33b64b3b
Date: 2019-08-09 15:32 +0200
http://bitbucket.org/pypy/pypy/changeset/1f0f33b64b3b/

Log:	Wrap the I/O errors we can get when importing modules (one more
	place)

diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -7,7 +7,7 @@
 from pypy.interpreter.module import Module
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, generic_new_descr
-from pypy.interpreter.error import OperationError, oefmt
+from pypy.interpreter.error import OperationError, oefmt, wrap_oserror
 from pypy.interpreter.baseobjspace import W_Root, CannotHaveLock
 from pypy.interpreter.eval import Code
 from pypy.interpreter.pycode import PyCode
@@ -923,7 +923,10 @@
     log_pyverbose(space, 1, "import %s # from %s\n" %
                   (space.text_w(w_modulename), pathname))
 
-    src_stat = os.fstat(fd)
+    try:
+        src_stat = os.fstat(fd)
+    except OSError as e:
+        raise wrap_oserror(space, e, pathname)   # better report this error
     cpathname = pathname + 'c'
     mtime = int(src_stat[stat.ST_MTIME])
     mode = src_stat[stat.ST_MODE]


More information about the pypy-commit mailing list