[pypy-commit] pypy py3k: fix test_argument.test_unicode_keywords by finally using unicode to store the exception message
antocuni
noreply at buildbot.pypy.org
Thu Aug 2 19:10:40 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r56537:b060ad64ed44
Date: 2012-08-02 18:23 +0200
http://bitbucket.org/pypy/pypy/changeset/b060ad64ed44/
Log: fix test_argument.test_unicode_keywords by finally using unicode to
store the exception message
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -2,6 +2,7 @@
Arguments objects.
"""
+from pypy.tool.sourcetools import with_unicode_literals
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.rlib.debug import make_sure_not_resized
from pypy.rlib import jit
@@ -214,6 +215,7 @@
self._do_combine_starstarargs_wrapped(keys_w, w_starstararg)
return True
+ @with_unicode_literals
def _do_combine_starstarargs_wrapped(self, keys_w, w_starstararg):
space = self.space
keywords_w = [None] * len(keys_w)
@@ -221,7 +223,7 @@
i = 0
for w_key in keys_w:
try:
- key = space.str_w(w_key)
+ key = space.unicode_w(w_key)
except OperationError, e:
if e.match(space, space.w_TypeError):
raise OperationError(
@@ -471,7 +473,7 @@
return co_argcount + has_vararg + has_kwarg + co_kwonlyargcount
-
+ @with_unicode_literals
def parse_into_scope(self, w_firstarg,
scope_w, fnname, signature, defaults_w=None,
w_kw_defs=None):
@@ -743,6 +745,7 @@
def __init__(self, argname):
self.argname = argname
+ @with_unicode_literals
def getmsg(self):
msg = "got multiple values for keyword argument '%s'" % (
self.argname)
@@ -778,6 +781,7 @@
break
self.kwd_name = name
+ @with_unicode_literals
def getmsg(self):
if self.num_kwds == 1:
msg = "got an unexpected keyword argument '%s'" % (
diff --git a/pypy/interpreter/test/test_argument.py b/pypy/interpreter/test/test_argument.py
--- a/pypy/interpreter/test/test_argument.py
+++ b/pypy/interpreter/test/test_argument.py
@@ -648,12 +648,9 @@
assert kwargs["美"] == 42
f(**{"美" : 42})
#
- # XXX: the following test fails because we cannot have error messages
- # with unicode characters yet, and it tries to build a message like:
- # "f() got an unexpected keyword argument 'ü'"
def f(x): pass
e = raises(TypeError, "f(**{'ü' : 19})")
- assert "'ü'" in str(e.value)
+ assert e.value.args[0] == "f() got an unexpected keyword argument 'ü'"
"""
def make_arguments_for_translation(space, args_w, keywords_w={},
More information about the pypy-commit
mailing list