Author: Ronan Lamy <ronan.l...@gmail.com> Branch: online-transforms Changeset: r74002:230d0daa9f89 Date: 2014-10-17 17:22 +0100 http://bitbucket.org/pypy/pypy/changeset/230d0daa9f89/
Log: pass the tests on CPython diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py --- a/rpython/annotator/bookkeeper.py +++ b/rpython/annotator/bookkeeper.py @@ -32,6 +32,9 @@ return ann_func return wrapped +CONTAINERS_S = [SomeList, SomeDict, SomeOrderedDict, SomeTuple] +_cls2Some = {cls.knowntype: cls for cls in CONTAINERS_S} + class Bookkeeper(object): """The log of choices that have been made while analysing the operations. It ensures that the same 'choice objects' will be returned if we ask @@ -318,8 +321,8 @@ result = s_self.find_method(x.__name__) assert result is not None elif hasattr(x, '__objclass__'): - s_type = self.valueoftype(x.__objclass__) - result = s_type.find_unboundmethod(x.__name__) + cls_s = self.annotationclass(x.__objclass__) + result = cls_s.find_unboundmethod(x.__name__) else: result = None if result is None: @@ -440,6 +443,12 @@ def valueoftype(self, t): return annotationoftype(t, self) + def annotationclass(self, cls): + try: + return _cls2Some[cls] + except KeyError: + return type(self.valueoftype(cls)) + def get_classpbc_attr_families(self, attrname): """Return the UnionFind for the ClassAttrFamilies corresponding to attributes of the given name. diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py --- a/rpython/annotator/unaryop.py +++ b/rpython/annotator/unaryop.py @@ -119,10 +119,11 @@ else: return SomeBuiltinMethod(analyser, self, name) - def find_unboundmethod(self, name): + @classmethod + def find_unboundmethod(cls, name): "Look for a special-case implementation for the named method." try: - analyser = getattr(self.__class__, 'method_' + name) + analyser = getattr(cls, 'method_' + name) except AttributeError: return None else: _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit