]> granicus.if.org Git - python/commitdiff
Fix SF bug #976608, Unhelpful error message when mtime of a module is -1
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 3 Oct 2005 04:48:15 +0000 (04:48 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 3 Oct 2005 04:48:15 +0000 (04:48 +0000)
Will backport.

Misc/NEWS
Python/import.c

index 0826013ef6793d3772cdd168366591bb9775f16e..c78fa69eca74243f2161ace3919bffb6f0d44bc8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 1?
 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 9b624a4cb614223aa84f6cefbaf04d92557608f1..35de13e5f9b8bb605b986155f0db36aee49157c7 100644 (file)
@@ -868,8 +868,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,