summaryrefslogtreecommitdiffstats
path: root/Mac/Python
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1998-08-18 12:23:11 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1998-08-18 12:23:11 (GMT)
commitb93f52158b57707cf94a51d5d66735d666be06d8 (patch)
treef474c02f0dc8d9ab7bae32e0838c265e10534f3d /Mac/Python
parent201f46de2c0ce193209ba24d68ce4ae711cac571 (diff)
downloadcpython-b93f52158b57707cf94a51d5d66735d666be06d8.zip
cpython-b93f52158b57707cf94a51d5d66735d666be06d8.tar.gz
cpython-b93f52158b57707cf94a51d5d66735d666be06d8.tar.bz2
Support for freezing packages (Just).
Diffstat (limited to 'Mac/Python')
-rw-r--r--Mac/Python/macimport.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/Mac/Python/macimport.c b/Mac/Python/macimport.c
index cf92543..f5f4e20 100644
--- a/Mac/Python/macimport.c
+++ b/Mac/Python/macimport.c
@@ -332,14 +332,45 @@ char *filename;
co = NULL;
} else {
co = PyMarshal_ReadObjectFromString((*h)+8, size-8);
+ /*
+ ** Normally, byte 4-7 are the time stamp, but that is not used
+ ** for 'PYC ' resources. We abuse byte 4 as a flag to indicate
+ ** that it is a package rather than an ordinary module.
+ ** See also py_resource.py. (jvr)
+ */
+ if ((*h)[4] & 0xff) {
+ /* it's a package */
+ /* Set __path__ to the package name */
+ PyObject *d, *s;
+ int err;
+
+ m = PyImport_AddModule(module);
+ if (m == NULL) {
+ co = NULL;
+ goto packageerror;
+ }
+ d = PyModule_GetDict(m);
+ s = PyString_InternFromString(module);
+ if (s == NULL) {
+ co = NULL;
+ goto packageerror;
+ }
+ err = PyDict_SetItemString(d, "__path__", s);
+ Py_DECREF(s);
+ if (err != 0) {
+ co = NULL;
+ goto packageerror;
+ }
+ }
}
}
+packageerror:
HUnlock(h);
if ( filerh != -1 )
CloseResFile(filerh);
UseResFile(oldrh);
if ( co ) {
- m = PyImport_ExecCodeModule(module, co);
+ m = PyImport_ExecCodeModuleEx(module, co, "<pyc resource>");
Py_DECREF(co);
} else {
m = NULL;