Barton Cline - 2010-10-17

My notes on this:
I've tested this and found that loading the python26.dll using the managed console app from the command line with the -O option specified DOES cause the .pyo file to be generated AND the __debug__ global to be True. Hmmm...

In Py_InitializeEx()
bimod = _PyBuiltin_Init();
if (bimod == NULL)
Py_FatalError("Py_Initialize: can't initialize __builtin__");
clearly succeeds.

So, in _PyBuiltin_Init()
debug = PyBool_FromLong(Py_OptimizeFlag == 0);
if (PyDict_SetItemString(dict, "__debug__", debug) < 0) {
Py_XDECREF(debug);
return NULL;
}
was also successful.

The Python.Runtime doesn't do anything to modify the __debug__ variable and, in fact, doesn't set any attributes on the __builtin__ module's __dict__. Therefore, it's unclear to me how to proceed on this one.

The obvious workaround is to use the CPython console and rely on the late bound import hook to take care of things.

Because I use wxPython for all my GUIs, the only option so far is to use pythonw.exe (packaged with PyInstaller - my only complaint being: too many DLLs which must be excluded from the build). I have seen no ill effects from using the late bound import hook. The only real reason I can see for doing otherwise is an interactive console session.

I appreciate any comments,
Barton