Skip to content

Commit 708e51a

Browse files
committed
Fix SF bug #976608, Unhelpful error message when mtime of a module is -1
Will backport.
1 parent a45770d commit 708e51a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 1?
1212
Core and builtins
1313
-----------------
1414

15+
- SF Bug #976608: fix SystemError when mtime of an imported file is -1.
16+
1517
- SF Bug #887946: fix segfault when redirecting stdin from a directory.
1618
Provide a warning when a directory is passed on the command line.
1719

Python/import.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,12 @@ load_source_module(char *name, char *pathname, FILE *fp)
868868
PyObject *m;
869869

870870
mtime = PyOS_GetLastModificationTime(pathname, fp);
871-
if (mtime == (time_t)(-1))
871+
if (mtime == (time_t)(-1)) {
872+
PyErr_Format(PyExc_RuntimeError,
873+
"unable to get modification time from '%s'",
874+
pathname);
872875
return NULL;
876+
}
873877
#if SIZEOF_TIME_T > 4
874878
/* Python's .pyc timestamp handling presumes that the timestamp fits
875879
in 4 bytes. This will be fine until sometime in the year 2038,

0 commit comments

Comments
 (0)