]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport:
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 3 Oct 2005 04:50:55 +0000 (04:50 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 3 Oct 2005 04:50:55 +0000 (04:50 +0000)
Fix SF bug #976608, Unhelpful error message when mtime of a module is -1

Misc/NEWS
Python/import.c

index 97043b316c810d2a77830982a1d8cef8d1910ac1..e29dd9567bb88cc33e95fc3a64858ea030be22cc 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.4.3c1?
 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.
 
index 460471403a4fbf9735064ce9e1be9f85e3e9b059..ee7c59300ee40c990550b4b3d81428bcbe95e320 100644 (file)
@@ -867,8 +867,12 @@ load_source_module(char *name, char *pathname, FILE *fp)
        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,