#endif
-extern long PyOS_GetLastModificationTime(); /* In getmtime.c */
+extern time_t PyOS_GetLastModificationTime(); /* In getmtime.c */
/* Magic word to reject .pyc files generated by other Python versions */
/* Change for each incompatible change */
make_compiled_pathname(pathname, buf, buflen)
char *pathname;
char *buf;
- int buflen;
+ size_t buflen;
{
- int len;
+ size_t len;
len = strlen(pathname);
if (len+2 > buflen)
char *pathname;
FILE *fp;
{
- long mtime;
+ time_t mtime;
FILE *fpc;
char buf[MAXPATHLEN+1];
char *cpathname;
PyObject *m;
mtime = PyOS_GetLastModificationTime(pathname, fp);
- cpathname = make_compiled_pathname(pathname, buf, MAXPATHLEN+1);
+ if (mtime == -1)
+ 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,
+ when a 4-byte signed time_t will overflow.
+ */
+ if (mtime >> 32) {
+ PyErr_SetString(PyExc_OverflowError,
+ "modification time overflows a 4 bytes");
+ return NULL;
+ }
+#endif
+ cpathname = make_compiled_pathname(pathname, buf, (size_t)MAXPATHLEN+1);
if (cpathname != NULL &&
(fpc = check_compiled_module(pathname, mtime, cpathname))) {
co = read_compiled_module(cpathname, fpc);
/* Forward */
static PyObject *load_module Py_PROTO((char *, FILE *, char *, int));
static struct filedescr *find_module Py_PROTO((char *, PyObject *,
- char *, int, FILE **));
+ char *, size_t, FILE **));
static struct _frozen *find_frozen Py_PROTO((char *name));
/* Load a package and return its module object WITH INCREMENTED
PyObject *path;
/* Output parameters: */
char *buf;
- int buflen;
+ size_t buflen;
FILE **p_fp;
{
- int i, npath, len, namelen;
+ int i, npath;
+ size_t len, namelen;
struct _frozen *f;
struct filedescr *fdp = NULL;
FILE *fp = NULL;
static struct filedescr fd_package = {"", "", PKG_DIRECTORY};
char name[MAXPATHLEN+1];
+ if (strlen(realname) > MAXPATHLEN) {
+ PyErr_SetString(PyExc_OverflowError, "module name is too long");
+ return NULL;
+ }
strcpy(name, realname);
if (path != NULL && PyString_Check(path)) {
if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen)
continue; /* Too long */
strcpy(buf, PyString_AsString(v));
- if ((int)strlen(buf) != len)
+ if (strlen(buf) != len)
continue; /* v contains '\0' */
#ifdef macintosh
#ifdef INTERN_STRINGS
find_init_module(buf)
char *buf;
{
- int save_len = strlen(buf);
- int i = save_len;
+ size_t save_len = strlen(buf);
+ size_t i = save_len;
struct stat statbuf;
if (save_len + 13 >= MAXPATHLEN)
else {
char *start = PyString_AS_STRING(modname);
char *lastdot = strrchr(start, '.');
- int len;
+ size_t len;
if (lastdot == NULL)
return Py_None;
len = lastdot - start;
{
char *name = *p_name;
char *dot = strchr(name, '.');
- int len;
+ size_t len;
char *p;
PyObject *result;