.pyo's without .pyc's?

Guido van Rossum guido at CNRI.Reston.VA.US
Thu Jul 8 09:09:28 EDT 1999


> I've checked this and indeed you're right. exceptions.py is imported
> prior to all other modules at a time where the switch from .pyc to
> .pyo hasn't been done yet (this is done in _PyImport_Init(), yet
> exceptions.py is imported by _PyBuiltin_Init_2()):
[...]
> Still, I think you're right in that the .pyc -> .pyo switch should
> be done prior to importing *any* Python module, meaning that
> _PyImport_Init() should be called prior to importing anything.

Hmm, seems you're right.  As Linus says, all bugs will eventually be
found.  Seems like this would be the fix, right?  (_PyImport_Init() is 
pretty trivial so I don't doubt that it works.)

Index: pythonrun.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/pythonrun.c,v
retrieving revision 2.88
diff -c -r2.88 pythonrun.c
*** pythonrun.c	1999/04/07 18:32:51	2.88
--- pythonrun.c	1999/07/08 13:06:43
***************
*** 149,160 ****
  	PyDict_SetItemString(interp->sysdict, "modules",
  			     interp->modules);
  
  	/* phase 2 of builtins */
  	_PyBuiltin_Init_2(interp->builtins);
  	_PyImport_FixupExtension("__builtin__", "__builtin__");
  
- 	_PyImport_Init();
- 
  	initsigs(); /* Signal handling stuff, including initintr() */
  
  	initmain(); /* Module __main__ */
--- 149,160 ----
  	PyDict_SetItemString(interp->sysdict, "modules",
  			     interp->modules);
  
+ 	_PyImport_Init();
+ 
  	/* phase 2 of builtins */
  	_PyBuiltin_Init_2(interp->builtins);
  	_PyImport_FixupExtension("__builtin__", "__builtin__");
  
  	initsigs(); /* Signal handling stuff, including initintr() */
  
  	initmain(); /* Module __main__ */

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-list mailing list