[pypy-commit] pypy default: backport part of 8fb4dc6f07e6
mattip
pypy.commits at gmail.com
Sun Feb 2 13:05:47 EST 2020
Author: Matti Picus <matti.picus at gmail.com>
Branch:
Changeset: r98644:0395c16d6bbe
Date: 2020-02-02 19:54 +0200
http://bitbucket.org/pypy/pypy/changeset/0395c16d6bbe/
Log: backport part of 8fb4dc6f07e6
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -14,6 +14,7 @@
from rpython.rlib.rutf8 import (check_utf8, next_codepoint_pos,
codepoints_in_utf8, codepoints_in_utf8,
Utf8StringBuilder)
+from rpython.rlib import rlocale
STATE_ZERO, STATE_OK, STATE_DETACHED = range(3)
@@ -235,6 +236,15 @@
if encoding is not None:
return space.newtext(encoding)
+ # Try to shortcut the app-level call if locale.CODESET works
+ if _WINDOWS:
+ return space.newtext(rlocale.getdefaultlocale()[1])
+ else:
+ if rlocale.HAVE_LANGINFO:
+ codeset = rlocale.nl_langinfo(rlocale.CODESET)
+ if codeset:
+ return space.newtext(codeset)
+
try:
w_locale = space.call_method(space.builtin, '__import__',
space.newtext('locale'))
More information about the pypy-commit
mailing list