[pypy-commit] pypy unicode-utf8: rework this to be more compliant - UnicodeError trumps TypeError

mattip pypy.commits at gmail.com
Tue Jan 1 08:31:25 EST 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8
Changeset: r95552:e79b16b3943d
Date: 2019-01-01 12:31 +0200
http://bitbucket.org/pypy/pypy/changeset/e79b16b3943d/

Log:	rework this to be more compliant - UnicodeError trumps TypeError

diff --git a/pypy/module/__builtin__/operation.py b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -45,11 +45,12 @@
     if not space.isinstance_w(w_name, space.w_text):
         try:
             name = space.text_w(w_name)    # typecheck
-        except Exception as e:
+        except OperationError as e:
+            if e.match(space, space.w_UnicodeError):
+                raise e
             raise oefmt(space.w_TypeError,
                  "%s(): attribute name must be string", msg)
-    if space.isinstance_w(w_name, space.w_unicode):
-        w_name = space.call_method(w_name, 'encode', space.newtext('ascii'))
+        w_name = space.newtext(w_name)
     return w_name
 
 def delattr(space, w_object, w_name):


More information about the pypy-commit mailing list