[pypy-commit] pypy unicode-utf8-py3: invalid utf8 in error message should not crash the interpreter
mattip
pypy.commits at gmail.com
Sat Feb 2 12:37:18 EST 2019
Author: Matti Picus <matti.picus at gmail.com>
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])
More information about the pypy-commit
mailing list