Commit ec35811f authored by Armin Rigo's avatar Armin Rigo

Fix comparison of lltype._ptr if they are delayed.

parent 63de72b5
......@@ -1154,7 +1154,12 @@ class _abstract_ptr(object):
type(other).__name__,))
if self._TYPE != other._TYPE:
raise TypeError("comparing %r and %r" % (self._TYPE, other._TYPE))
return self._obj == other._obj
try:
return self._obj == other._obj
except DelayedPointer:
# if one of the two pointers is delayed, they cannot
# possibly be equal unless they are the same _ptr instance
return self is other
def __ne__(self, other):
return not (self == other)
......
......@@ -64,3 +64,13 @@ class TestLLType(BaseRtypingTest):
assert lltype.typeOf(ptr) == OBJECTPTR
y = annlowlevel.cast_base_ptr_to_instance(X, ptr)
assert y is x
def test_delayedptr(self):
FUNCTYPE = lltype.FuncType([], lltype.Signed)
name = "delayed!myfunc"
delayedptr1 = lltype._ptr(lltype.Ptr(FUNCTYPE), name, solid=True)
delayedptr2 = lltype._ptr(lltype.Ptr(FUNCTYPE), name, solid=True)
assert delayedptr1 == delayedptr1
assert delayedptr1 != delayedptr2
assert bool(delayedptr1)
assert delayedptr1 != lltype.nullptr(FUNCTYPE)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment