Author: Tyler Wade <way...@gmail.com>
Branch: utf8-unicode2
Changeset: r72700:a70bb8e0da3c
Date: 2014-08-05 13:24 -0500
http://bitbucket.org/pypy/pypy/changeset/a70bb8e0da3c/

Log:    Fix raw-unicode-escape codec

diff --git a/pypy/interpreter/test/test_utf8_codecs.py 
b/pypy/interpreter/test/test_utf8_codecs.py
--- a/pypy/interpreter/test/test_utf8_codecs.py
+++ b/pypy/interpreter/test/test_utf8_codecs.py
@@ -740,6 +740,12 @@
                        Utf8Str.from_unicode(u' 12, \u1234 '), 7, None)
         assert encoder(Utf8Str.from_unicode(u'u\u1234'), 2, 'replace') == 'u?'
 
+    def test_decode_raw_unicode_escape(self):
+        decoder = self.getdecoder('raw-unicode-escape')
+        s = '\xffab\x80\n'
+        u = Utf8Str.from_unicode(unicode(s, 'raw-unicode-escape'))
+        assert decoder(s, len(s), 'strict')[0] == u
+
 
 class TestTranslation(object):
     def test_utf8(self):
diff --git a/pypy/interpreter/utf8_codecs.py b/pypy/interpreter/utf8_codecs.py
--- a/pypy/interpreter/utf8_codecs.py
+++ b/pypy/interpreter/utf8_codecs.py
@@ -288,7 +288,7 @@
 
         # Non-escape characters are interpreted as Unicode ordinals
         if ch != '\\':
-            result.append(ch)
+            result.append(ord(ch))
             pos += 1
             continue
 
@@ -310,7 +310,7 @@
             pos >= size or
             (s[pos] != 'u' and s[pos] != 'U')):
             result.append('\\')
-            result.append(s[pos])
+            result.append(ord(s[pos]))
             pos += 1
             continue
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to