I've recently noticed that in py3k, the lack of a suitable sys.path will cause Py_FatalError() to be called, which immediately terminates the entire application.

On Windows, it is fairly easy for this to happen for developers or anyone who hasn't run the official Python installation; just have Python used in a 'service', web server, COM object or anything else which loads python3x.dll from the system32 etc directory, and neglect to have added the PYTHONPATH entry in the registry or global environment. As a result Python can't sniff a good default sys.path, fails to import encodings, then winds up calling Py_FatalError("Py_Initialize: can't initialize sys standard streams");

I realize this is something of an edge-case, but having abort() called on the application in this case is somewhat harsh and difficult to diagnose. In Python 2.x, you end up with a fairly crippled Python environment, but it functions well enough to offer clues that your sys.path isn't setup.

Would it be practical and desirable to handle this situation more gracefully, possibly just leaving sys.std* set to None and letting whatever exceptions then occur happen as normal without terminating the process? Given it is an edge-case, I thought I'd open it here for discussion before putting work into a patch or opening a bug.

Thanks,

Mark
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to