[pypy-commit] pypy default: do not crash on random input

mattip noreply at buildbot.pypy.org
Wed Feb 6 09:59:08 CET 2013


Author: mattip
Branch: 
Changeset: r60899:e8f4b8257bf2
Date: 2013-02-06 10:59 +0200
http://bitbucket.org/pypy/pypy/changeset/e8f4b8257bf2/

Log:	do not crash on random input

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -31,7 +31,8 @@
         ch2 = ord(u[1])
         if 0xD800 <= ch1 <= 0xDBFF and 0xDC00 <= ch2 <= 0xDFFF:
             return (((ch1 - 0xD800) << 10) | (ch2 - 0xDC00)) + 0x10000
-    assert len(u) == 1
+    if len(u) != 1:
+        raise ValueError('not a surrogate')
     return ord(u[0])
 
 if MAXUNICODE > sys.maxunicode:


More information about the pypy-commit mailing list