[pypy-commit] pypy py3k: backout 81cd817ffe62, I'll try another approach for unicode exception messages
antocuni
noreply at buildbot.pypy.org
Sat Aug 4 15:01:15 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r56566:445a23b4a25a
Date: 2012-08-04 14:42 +0200
http://bitbucket.org/pypy/pypy/changeset/445a23b4a25a/
Log: backout 81cd817ffe62, I'll try another approach for unicode
exception messages
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -320,12 +320,10 @@
return tuple(parts), tuple(formats)
def get_operrcls2(valuefmt):
- is_unicode = isinstance(valuefmt, unicode)
strings, formats = decompose_valuefmt(valuefmt)
- key = (is_unicode, formats)
assert len(strings) == len(formats) + 1
try:
- OpErrFmt = _fmtcache2[key]
+ OpErrFmt = _fmtcache2[formats]
except KeyError:
from pypy.rlib.unroll import unrolling_iterable
attrs = ['x%d' % i for i in range(len(formats))]
@@ -347,17 +345,11 @@
string = self.xstrings[i]
value = getattr(self, attr)
lst[i+i] = string
- if is_unicode:
- lst[i+i+1] = unicode(value)
- else:
- lst[i+i+1] = str(value)
+ lst[i+i+1] = str(value)
lst[-1] = self.xstrings[-1]
- if is_unicode:
- return u''.join(lst)
- else:
- return ''.join(lst)
+ return ''.join(lst)
#
- _fmtcache2[key] = OpErrFmt
+ _fmtcache2[formats] = OpErrFmt
return OpErrFmt, strings
def get_operationerr_class(valuefmt):
diff --git a/pypy/interpreter/test/test_error.py b/pypy/interpreter/test/test_error.py
--- a/pypy/interpreter/test/test_error.py
+++ b/pypy/interpreter/test/test_error.py
@@ -1,4 +1,3 @@
-# -*- encoding: utf-8 -*-
import py, os, errno
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.error import decompose_valuefmt, get_operrcls2
@@ -34,13 +33,6 @@
operr3 = operationerrfmt("w_type2", "a %s b %s c", "bar", "4b")
assert operr3.__class__ is not operr.__class__
-def test_operationerrfmt_unicode():
- operr = operationerrfmt("w_type", u"abc %s def %d", u"àèì", 42)
- assert isinstance(operr, OperationError)
- assert operr.w_type == "w_type"
- assert operr._w_value is None
- assert operr._compute_value() == u"abc àèì def 42"
-
def test_operationerrfmt_empty():
py.test.raises(AssertionError, operationerrfmt, "w_type", "foobar")
More information about the pypy-commit
mailing list