summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/Python/import.c b/Python/import.c
index ca3de3d..4239e12 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -48,9 +48,13 @@ extern int verbose; /* Defined in pythonrun.c */
extern long getmtime(); /* In getmtime.c */
/* Magic word to reject .pyc files generated by other Python versions */
-/* Increment by one for each incompatible change */
-/* MPW swaps CR and LF, so their value is incorporated as well */
-#define MAGIC (0x999903L ^ (('\n'^10L)<<16) ^ (('\r'^13L)<<8))
+/* Change for each incompatible change */
+/* The value of CR and LF is incorporated so if you ever read or write
+ a .pyc file in text mode the magic number will be wrong; also, the
+ Apple MPW compiler swaps their values, botching string constants */
+/* XXX Perhaps the magic number should be frozen and a version field
+ added to the .pyc file header? */
+#define MAGIC (0x4127L | ((long)'\r'<<16) | ((long)'\n'<<24))
object *import_modules; /* This becomes sys.modules */
@@ -847,7 +851,7 @@ imp_load_compiled(self, args)
object *fob = NULL;
object *m;
FILE *fp;
- if (!newgetargs(args, "ss|O!", &name, &pathname, &Filetype, &fob))
+ if (!newgetargs(args, "ssO!", &name, &pathname, &Filetype, &fob))
return NULL;
fp = get_file(pathname, fob, "rb");
if (fp == NULL)
@@ -865,10 +869,17 @@ imp_load_dynamic(self, args)
{
char *name;
char *pathname;
- object *dummy;
- if (!newgetargs(args, "ss|O", &name, &pathname, &dummy))
+ object *fob = NULL;
+ object *m;
+ FILE *fp = NULL;
+ if (!newgetargs(args, "ss|O!", &name, &pathname, &Filetype, &fob))
return NULL;
- return load_dynamic_module(name, pathname, NULL);
+ if (fob)
+ fp = get_file(pathname, fob, "r");
+ m = load_dynamic_module(name, pathname, fp);
+ if (fob == NULL)
+ fclose(fp);
+ return m;
}
static object *
@@ -881,7 +892,7 @@ imp_load_source(self, args)
object *fob = NULL;
object *m;
FILE *fp;
- if (!newgetargs(args, "ss|O!", &name, &pathname, &Filetype, &fob))
+ if (!newgetargs(args, "ssO!", &name, &pathname, &Filetype, &fob))
return NULL;
fp = get_file(pathname, fob, "r");
if (fp == NULL)