[pypy-svn] r14916 - in pypy/dist/pypy: objspace/std translator/goal translator/test
arigo at codespeak.net
arigo at codespeak.net
Fri Jul 22 16:43:09 CEST 2005
Author: arigo
Date: Fri Jul 22 16:43:07 2005
New Revision: 14916
Modified:
pypy/dist/pypy/objspace/std/listobject.py
pypy/dist/pypy/translator/goal/ISSUES.txt
pypy/dist/pypy/translator/test/test_annrpython.py
Log:
All the subclasses of TimSort should inherit from a common subclass,
to hide the parent method TimSort.lt() from the annotator.
Added a test that shows that this really hides the parent method.
Modified: pypy/dist/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/listobject.py (original)
+++ pypy/dist/pypy/objspace/std/listobject.py Fri Jul 22 16:43:07 2005
@@ -571,12 +571,16 @@
self.w_key = w_key
self.w_item = w_item
+# NOTE: all the subclasses of TimSort should inherit from a common subclass,
+# so make sure that only SimpleSort inherits directly from TimSort.
+# This is necessary to hide the parent method TimSort.lt() from the
+# annotator.
class SimpleSort(TimSort):
def lt(self, a, b):
space = self.space
return space.is_true(space.lt(a, b))
-class CustomCompareSort(TimSort):
+class CustomCompareSort(SimpleSort):
def lt(self, a, b):
space = self.space
w_cmp = self.w_cmp
@@ -590,7 +594,7 @@
raise
return result < 0
-class CustomKeySort(TimSort):
+class CustomKeySort(SimpleSort):
def lt(self, a, b):
assert isinstance(a, KeyContainer)
assert isinstance(b, KeyContainer)
Modified: pypy/dist/pypy/translator/goal/ISSUES.txt
==============================================================================
--- pypy/dist/pypy/translator/goal/ISSUES.txt (original)
+++ pypy/dist/pypy/translator/goal/ISSUES.txt Fri Jul 22 16:43:07 2005
@@ -13,11 +13,6 @@
.. block at -1 EH with 2 exits(v701741)
.. v701737 = simple_call((builtin_function_or_method hasattr), v701728, ('fakedcpytype'))
- TyperError-2: (pypy.objspace.std.listsort:lt)
- unimplemented operation: 'lt' on (<InstanceRepr for pypy.interpreter.baseobjspace.W_Root>, <InstanceRepr for pypy.interpreter.baseobjspace.W_Root>)
- .. block at -1 with 1 exits
- .. v795189 = lt(a_795178, b_795179)
-
TyperError-3: (pypy.module.sys.vm:getrefcount)
don't know about built-in function <built-in function getrefcount>
.. block at -1 with 1 exits
Modified: pypy/dist/pypy/translator/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_annrpython.py (original)
+++ pypy/dist/pypy/translator/test/test_annrpython.py Fri Jul 22 16:43:07 2005
@@ -1439,8 +1439,28 @@
s = a.build_types(f, [float])
assert s.const == "dontknow"
-
-
+ def test_hidden_method(self):
+ class Base:
+ def method(self):
+ return ["should be hidden"]
+ def indirect(self):
+ return self.method()
+ class A(Base):
+ def method(self):
+ return "visible"
+ class B(A):
+ def method(self):
+ return None
+ def f(flag):
+ if flag:
+ obj = A()
+ else:
+ obj = B()
+ return obj.indirect()
+ a = self.RPythonAnnotator()
+ s = a.build_types(f, [bool])
+ assert s == annmodel.SomeString(can_be_None=True)
+
def g(n):
return [0,1,2,n]
More information about the Pypy-commit
mailing list