Message199367
The io module doesn't need to set temporarly the LC_CTYPE locale (which is a good thing because the change is process-wide!). If we ignore systems where CODESET is not available, the _bootlocale can be simplified to a few lines:
if sys.platform.startswith("win"):
def getpreferredencoding():
import _locale
return _locale._getdefaultlocale()[1]
else:
def getpreferredencoding():
result = nl_langinfo(CODESET)
if not result and sys.platform == 'darwin':
result = 'UTF-8'
return result
This code can probably be implemented in C, directly in the _locale module. Would it be acceptable to modify the io module to replace locale.getpreferredencoding(False) with _locale.getpreferredencoding(False)?
Does anyone know if Python does still support systems where CODESET is not available? Which OS does not support CODESET? Would it be acceptable to fallback to locale.py if CODESET is not available? |
|
Date |
User |
Action |
Args |
2013-10-10 07:58:25 | vstinner | set | recipients:
+ vstinner, lemburg, barry, brett.cannon, rhettinger, mark.dickinson, ncoghlan, orsenthil, pitrou, christian.heimes, benjamin.peterson, eric.araujo, Arfrever, flox, eric.snow |
2013-10-10 07:58:25 | vstinner | set | messageid: <1381391905.39.0.927277578166.issue9548@psf.upfronthosting.co.za> |
2013-10-10 07:58:25 | vstinner | link | issue9548 messages |
2013-10-10 07:58:25 | vstinner | create | |
|