Message9430

Author zyasoft
Recipients amak, fwierzbicki, pekka.klarck, zyasoft
Date 2015-01-20.23:29:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1421796576.61.0.577712315374.issue1841@psf.upfronthosting.co.za>
In-reply-to
Content
Setting os.environ should be done with Unicode, but we can support bytes as well if we have an encoding. Otherwise we will get an error like so:

======================================================================
ERROR: test_env_bytes (__main__.OSUnicodeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "dist/Lib/test/test_os_jy.py", line 147, in test_env_bytes
    newenv["TEST_HOME"] = u"首页".decode("utf-8")
  File "/Users/jbaker/jythondev/jython27/dist/Lib/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value

But what to choose from?

* ascii - a good default choice that prevents silent error propagation
* sys.getdefaultencoding() appears to always return "ascii"; it's not really changeable, https://docs.python.org/2/library/sys.html#sys.setdefaultencoding Let's double check this by someone running a non US system.
* sys.getfilesystemencoding() always returs None, which is legal ("or None if the system default encoding is used", https://docs.python.org/2/library/sys.html#sys.getfilesystemencoding). Let's not change this.
* python.console.encoding really should be about the console
* python.io.encoding (= env variable PYTHONIOENCODING) is new in 2.7 and corresponds to what is available since 2.6 in CPython
History
Date User Action Args
2015-01-20 23:29:36zyasoftsetmessageid: <1421796576.61.0.577712315374.issue1841@psf.upfronthosting.co.za>
2015-01-20 23:29:36zyasoftsetrecipients: + zyasoft, fwierzbicki, amak, pekka.klarck
2015-01-20 23:29:36zyasoftlinkissue1841 messages
2015-01-20 23:29:35zyasoftcreate