Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r95776:64938735299b
Date: 2019-02-02 17:29 +0200
http://bitbucket.org/pypy/pypy/changeset/64938735299b/

Log:    invalid utf8 in error message should not crash the interpreter

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -526,8 +526,10 @@
                     else:
                         from rpython.rlib import rutf8
                         result = str(value)
-                        # Assumes valid utf-8
-                        lgt += rutf8.check_utf8(result, True)
+                        try:
+                            lgt += rutf8.check_utf8(result, True)
+                        except rutf8.CheckError as e:
+                            lgt -= e.pos
                     lst[i + i + 1] = result
                 lst[-1] = self.xstrings[-1]
                 lgt += len(self.xstrings[-1])
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to