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 christian.heimes
Recipients barry, christian.heimes
Date 2008-10-27.13:29:12
SpamBayes Score 4.41314e-14
Marked as misclassified No
Message-id <1225114155.31.0.609003653611.issue4213@psf.upfronthosting.co.za>
In-reply-to
Content
Python should lower case the file system encoding in Python/pythonrun.c.
On several occasions Python optimizes code paths for lower case
encodings like "utf-8" or "latin-1". On my Ubuntu system the file system
encoding is upper case ("UTF-8") and the optimizations aren't used. This
also causes problems with sub interpreters #3723 initstdio() in the sub
interpreter fails because "UTF-8" must be looked up in the codecs and
encoding registry while "utf-8" works like a charm.

$ python2.6 -c "import sys; print sys.getfilesystemencoding()"
UTF-8

$ python3.0 -c "import sys; print(sys.getfilesystemencoding())"
UTF-8

$ locale
LANG=de_DE.UTF-8
LANGUAGE=en_US:en:de_DE:de
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

The patch is trivial:

	if (codeset) {
		if (!Py_FileSystemDefaultEncoding) {
			char *p;
			for (p=codeset; *p; p++)
				*p = tolower(*p);
			Py_FileSystemDefaultEncoding = codeset;
                }
		else
			free(codeset);
	}

Python/codecs.c:normalizestring() does a similar job. Maybe a new method
"char* PyCodec_NormalizeEncodingName(const char*)" could be introduced
for the problem.
History
Date User Action Args
2008-10-27 13:29:15christian.heimessetrecipients: + christian.heimes, barry
2008-10-27 13:29:15christian.heimessetmessageid: <1225114155.31.0.609003653611.issue4213@psf.upfronthosting.co.za>
2008-10-27 13:29:13christian.heimeslinkissue4213 messages
2008-10-27 13:29:12christian.heimescreate