summaryrefslogtreecommitdiffstats
path: root/Python/getmtime.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-09-05 07:33:22 (GMT)
committerGuido van Rossum <guido@python.org>1997-09-05 07:33:22 (GMT)
commitaee0bad0a50f9f533267d241bea97a0b2118f238 (patch)
tree636ee14fc00351167bfea4c341ada498730f1cc2 /Python/getmtime.c
parent026de19906695cc0f63977da4e7740214048ba6f (diff)
downloadcpython-aee0bad0a50f9f533267d241bea97a0b2118f238.zip
cpython-aee0bad0a50f9f533267d241bea97a0b2118f238.tar.gz
cpython-aee0bad0a50f9f533267d241bea97a0b2118f238.tar.bz2
First part of package support.
This doesn't yet support "import a.b.c" or "from a.b.c import x", but it does recognize directories. When importing a directory, it initializes __path__ to a list containing the directory name, and loads the __init__ module if found. The (internal) find_module() and load_module() functions are restructured so that they both also handle built-in and frozen modules and Mac resources (and directories of course). The imp module's find_module() and (new) load_module() also have this functionality. Moreover, imp unconditionally defines constants for all module types, and has two more new functions: find_module_in_package() and find_module_in_directory(). There's also a new API function, PyImport_ImportModuleEx(), which takes all four __import__ arguments (name, globals, locals, fromlist). The last three may be NULL. This is currently the same as PyImport_ImportModule() but in the future it will be able to do relative dotted-path imports. Other changes: - bltinmodule.c: in __import__, call PyImport_ImportModuleEx(). - ceval.c: always pass the fromlist to __import__, even if it is a C function, so PyImport_ImportModuleEx() is useful. - getmtime.c: the function has a second argument, the FILE*, on which it applies fstat(). According to Sjoerd this is much faster. The first (pathname) argument is ignored, but remains for backward compatibility (so the Mac version still works without changes). By cleverly combining the new imp functionality, the full support for dotted names in Python (mini.py, not checked in) is now about 7K, lavishly commented (vs. 14K for ni plus 11K for ihooks, also lavishly commented). Good night!
Diffstat (limited to 'Python/getmtime.c')
-rw-r--r--Python/getmtime.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/getmtime.c b/Python/getmtime.c
index 793c663..4bf2adf 100644
--- a/Python/getmtime.c
+++ b/Python/getmtime.c
@@ -35,15 +35,17 @@ PERFORMANCE OF THIS SOFTWARE.
#include "config.h"
+#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
long
-PyOS_GetLastModificationTime(path)
+PyOS_GetLastModificationTime(path, fp)
char *path;
+ FILE *fp;
{
struct stat st;
- if (stat(path, &st) != 0)
+ if (fstat(fileno(fp), &st) != 0)
return -1;
else
return st.st_mtime;