[Python-Dev] Segmentaion fault with wrongly set PYTHONPATH on Windows

Stephen J. Turnbull turnbull at sk.tsukuba.ac.jp
Tue Oct 23 01:39:03 CEST 2012


anatoly techtonik writes:

 > I am not a C coder and don't have any core Unix programming
 > background. If Python is unable to start because it can not find its
 > libraries, I prefer an explanative error message with standard system
 > error code. Even if it is Fatal Python error - this case is still in
 > user land and should be fixed normally.

Python can't know that the problem is in "user land" as you call it.
For all Python knows, the directory containing its libraries is
corrupt, or that the file system code itself experienced a mysterious
glitch.

While in the technical sense the problem here is in userland, not in
the kernel, the distinction you're making is incoherent.  For most
users, it doesn't matter whether an environment variable is set
incorrectly without their knowledge, or if the kernel is buggy, or if
the disk is corrupt.  And from Python's point of view, the world as a
whole no longer makes.

So it shuts down abnormally.  That's what an abort means, in
programming as in rocket launches.  Users should be scared if this
happens; somebody really screwed up.  (Unless it's themselves, and
then they only have themselves to blame.)

 > The error message could be
 > improved though. Right now I get:
 > 
 > E:\>python
 > Fatal Python error: Py_Initialize: unable to load the file system codec
 > ImportError: No module named 'encodings'
 > 
 > This could be improved to:
 > 
 > Fatal Python error: Py_Initialize: unable to find module named 'encodings'
 > in 'C:\'

That may be an improvement.  But in that case it might be worth
explaining where "C:\" came from (in this case PYTHONHOME, I guess?)



More information about the Python-Dev mailing list