[pypy-commit] pypy py3k: bah, there are two levels of memo/cache, and we need to specialize for unicode formatting strings on both levels

antocuni noreply at buildbot.pypy.org
Thu Aug 2 19:10:46 CEST 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r56542:5226ba3dc28d
Date: 2012-08-02 18:56 +0200
http://bitbucket.org/pypy/pypy/changeset/5226ba3dc28d/

Log:	bah, there are two levels of memo/cache, and we need to specialize
	for unicode formatting strings on both levels

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -361,10 +361,12 @@
     return OpErrFmt, strings
 
 def get_operationerr_class(valuefmt):
+    is_unicode = isinstance(valuefmt, unicode)
+    key = (is_unicode, valuefmt)
     try:
-        result = _fmtcache[valuefmt]
+        result = _fmtcache[key]
     except KeyError:
-        result = _fmtcache[valuefmt] = get_operrcls2(valuefmt)
+        result = _fmtcache[key] = get_operrcls2(valuefmt)
     return result
 get_operationerr_class._annspecialcase_ = 'specialize:memo'
 


More information about the pypy-commit mailing list