Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.

This commit is contained in:
Georg Brandl 2008-01-07 17:09:35 +00:00
parent b3255ed8c9
commit 2da0fceba7
8 changed files with 56 additions and 8 deletions

View file

@ -950,8 +950,11 @@ load_source_module(char *name, char *pathname, FILE *fp)
if (Py_VerboseFlag)
PySys_WriteStderr("import %s # from %s\n",
name, pathname);
if (cpathname)
write_compiled_module(co, cpathname, mtime);
if (cpathname) {
PyObject *ro = PySys_GetObject("dont_write_bytecode");
if (ro == NULL || !PyObject_IsTrue(ro))
write_compiled_module(co, cpathname, mtime);
}
}
m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname);
Py_DECREF(co);