Fix SF bug #976608, Unhelpful error message when mtime of a module is -1
Will backport.
diff --git a/Misc/NEWS b/Misc/NEWS
index 0826013..c78fa69 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@
Core and builtins
-----------------
+- SF Bug #976608: fix SystemError when mtime of an imported file is -1.
+
- SF Bug #887946: fix segfault when redirecting stdin from a directory.
Provide a warning when a directory is passed on the command line.
diff --git a/Python/import.c b/Python/import.c
index 9b624a4..35de13e 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -868,8 +868,12 @@
PyObject *m;
mtime = PyOS_GetLastModificationTime(pathname, fp);
- if (mtime == (time_t)(-1))
+ if (mtime == (time_t)(-1)) {
+ PyErr_Format(PyExc_RuntimeError,
+ "unable to get modification time from '%s'",
+ pathname);
return NULL;
+ }
#if SIZEOF_TIME_T > 4
/* Python's .pyc timestamp handling presumes that the timestamp fits
in 4 bytes. This will be fine until sometime in the year 2038,