[pypy-commit] pypy record-known-result: re-decoding a utf-8 encoded byte string needs to do nothing

cfbolz pypy.commits at gmail.com
Wed Oct 16 08:45:12 EDT 2019


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: record-known-result
Changeset: r97790:270b9c958d32
Date: 2019-10-16 14:44 +0200
http://bitbucket.org/pypy/pypy/changeset/270b9c958d32/

Log:	re-decoding a utf-8 encoded byte string needs to do nothing

diff --git a/dotviewer/graphclient.py b/dotviewer/graphclient.py
--- a/dotviewer/graphclient.py
+++ b/dotviewer/graphclient.py
@@ -95,8 +95,8 @@
     except EOFError:
         ioerror = ioerror or IOError("connection unexpectedly closed "
                                      "(graphserver crash?)")
-    #if ioerror is not None:
-    #    raise ioerror
+    if ioerror is not None:
+        raise ioerror
 
 def send_error(io, e):
     try:
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -289,3 +289,23 @@
             i57 = int_sub(i52, i56)
             i59 = int_sub(i38, 1)
         ''')
+
+    def test_decode_encode(self):
+        log = self.run("""
+        def main(n):
+            global s
+            u = b'ab\xc3\xa4\xf0\x9f\x91\xa9\xe2\x80\x8d\xf0\x9f\x91\xa9\xe2\x80\x8d\xf0\x9f\x91\xa7\xe2\x80\x8d\xf0\x9f\x91\xa6'.decode("utf-8")
+            count = 0
+            for i in range(n):
+                b = (u + unicode(i)).encode("utf-8")
+                u = b.decode("utf-8") # ID: decode
+                count += 1
+            return count
+        """, [10000])
+        loop, = log.loops_by_filename(self.filepath)
+        # No call to _check_utf8 is necessary, because the bytes come from
+        # W_UnicodeObject.utf8_w.
+        assert loop.match_by_id('decode', '''
+            i95 = int_ge(i86, 0)
+            guard_true(i95, descr=...)
+        ''')


More information about the pypy-commit mailing list