This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients amaury.forgeotdarc, belopolsky, flox, grahamd, pitrou
Date 2011-02-02.21:23:00
SpamBayes Score 5.945244e-14
Marked as misclassified No
Message-id <1296681781.68.0.185211338239.issue6501@psf.upfronthosting.co.za>
In-reply-to
Content
The issue is not Windows specific, so I am changing the title to reflect that.   On OSX, for example, I get

$ PYTHONIOENCODING=xyz ./python.exe
Fatal Python error: Py_Initialize: can't initialize sys standard streams
LookupError: unknown encoding: xyz
Abort trap

I agree that abort() is too drastic for a typo in the environment variable setting, but ignoring it silently is not a good option either.  Someone setting PYTHONIOENCODING most likely does it for a reason and giving him or her some sort of default behavior for mistyped encoding is not helpful.  (Note that this is how many C libraries treat TZ environment variable setting and this is often very frustrating.)

I think errors in environment variables that can be detected on startup should be treated the same way as the command line typos: a descriptive message on C stderr and exit(1).

Currently different environment variables are treated differently.  For example, mistakes in PYTHONHOME and PYTHONIOENCODING cause fatal error while an error in PYTHONSTARTUP is reported but does not terminate python:

$ PYTHONSTARTUP=xyz.py ./python.exe
Python 3.2rc2+ (py3k:88320, Feb  2 2011, 14:07:18) 
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Could not open PYTHONSTARTUP
IOError: [Errno 2] No such file or directory: 'xyz.py'
>>>
History
Date User Action Args
2011-02-02 21:23:01belopolskysetrecipients: + belopolsky, amaury.forgeotdarc, pitrou, grahamd, flox
2011-02-02 21:23:01belopolskysetmessageid: <1296681781.68.0.185211338239.issue6501@psf.upfronthosting.co.za>
2011-02-02 21:23:01belopolskylinkissue6501 messages
2011-02-02 21:23:00belopolskycreate