Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r95075:f7c1e87b6a3c
Date: 2018-09-02 11:25 +0200
http://bitbucket.org/pypy/pypy/changeset/f7c1e87b6a3c/
Log: check class name for valid utf8
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -14,6 +14,7 @@
from rpython.rlib.objectmodel import current_object_addr_as_int, compute_hash
from rpython.rlib.objectmodel import we_are_translated, not_rpython
from rpython.rlib.rarithmetic import intmask, r_uint
+from rpython.rlib.rutf8 import CheckError, check_utf8
class MutableCell(W_Root):
def unwrap_cell(self, space):
@@ -177,6 +178,15 @@
overridetypedef=None, force_new_layout=False,
is_heaptype=True):
self.space = space
+ try:
+ check_utf8(name, False)
+ except CheckError as e:
+ raise OperationError(space.w_UnicodeEncodeError,
+ space.newtuple([space.newtext('utf8'),
+ space.newtext(name),
+ space.newint(e.pos),
+ space.newint(e.pos + 1),
+ space.newtext('surrogates not allowed')]))
self.name = name
self.qualname = None
self.bases_w = bases_w
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit