Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r95400:58cac9f73bf3
Date: 2018-12-01 05:19 -0800
http://bitbucket.org/pypy/pypy/changeset/58cac9f73bf3/
Log: fix failing tests
diff --git a/pypy/interpreter/unicodehelper.py
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -1732,13 +1732,17 @@
r, newindex, rettype = errorhandler(errors, "charmap",
"character maps to <undefined>",
s, startindex, index)
- for cp2 in rutf8.Utf8StringIterator(r):
- ch2 = mapping.get(cp2, '')
- if not ch2:
- errorhandler(
- "strict", "charmap", "character maps to <undefined>",
- s, startindex, index)
- result.append(ch2)
+ if rettype == 'u':
+ for cp2 in rutf8.Utf8StringIterator(r):
+ ch2 = mapping.get(cp2, '')
+ if not ch2:
+ errorhandler(
+ "strict", "charmap", "character maps to
<undefined>",
+ s, startindex, index)
+ result.append(ch2)
+ else:
+ for ch in r:
+ result.append(ch)
if index != newindex: # Should be uncommon
index = newindex
pos = rutf8._pos_at_index(s, newindex)
diff --git a/pypy/module/_locale/interp_locale.py
b/pypy/module/_locale/interp_locale.py
--- a/pypy/module/_locale/interp_locale.py
+++ b/pypy/module/_locale/interp_locale.py
@@ -41,8 +41,9 @@
def charp2uni(space, s):
"Convert a char* pointer to unicode according to the current locale"
- # XXX use mbstowcs()
- return space.newtext(rffi.charp2str(s))
+ w_val = space.newbytes(rffi.charp2str(s))
+ return space.call_function(space.w_unicode, w_val, space.newtext('utf-8'),
+ space.newtext('surrogateescape'))
def localeconv(space):
"() -> dict. Returns numeric and monetary locale-specific parameters."
@@ -146,9 +147,11 @@
Return the value for the locale information associated with key."""
try:
- return space.newtext(rlocale.nl_langinfo(key))
+ w_val = space.newbytes(rlocale.nl_langinfo(key))
except ValueError:
raise oefmt(space.w_ValueError, "unsupported langinfo constant")
+ return space.call_function(space.w_unicode, w_val,
+ space.newtext('utf-8'), space.newtext('surrogateescape'))
#___________________________________________________________________
# HAVE_LIBINTL dependence
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit