aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Cuni <anto.cuni@gmail.com>2007-09-14 09:53:28 +0000
committerAntonio Cuni <anto.cuni@gmail.com>2007-09-14 09:53:28 +0000
commita002baead604d885be276b7e411a82d446702c9f (patch)
treea5f7fa93e2d914f088dbcbc86cef4a69b8b6b8c7 /pypy/rpython/rweakref.py
parentImplement automatic GIL release around external function calls. (diff)
downloadpypy-a002baead604d885be276b7e411a82d446702c9f.tar.gz
pypy-a002baead604d885be276b7e411a82d446702c9f.tar.bz2
pypy-a002baead604d885be276b7e411a82d446702c9f.zip
allow null weakref in both lltype and ootype
Diffstat (limited to 'pypy/rpython/rweakref.py')
-rw-r--r--pypy/rpython/rweakref.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/pypy/rpython/rweakref.py b/pypy/rpython/rweakref.py
index 8b74351828..aff736cb61 100644
--- a/pypy/rpython/rweakref.py
+++ b/pypy/rpython/rweakref.py
@@ -29,6 +29,9 @@ class BaseWeakRefRepr(Repr):
"this backend or GC policy")
def convert_const(self, value):
+ if value is None:
+ return self.null_wref
+
assert isinstance(value, weakref.ReferenceType)
instance = value()
bk = self.rtyper.annotator.bookkeeper
@@ -47,6 +50,7 @@ class BaseWeakRefRepr(Repr):
class LLWeakRefRepr(BaseWeakRefRepr):
lowleveltype = llmemory.WeakRefPtr
dead_wref = llmemory.dead_wref
+ null_wref = lltype.nullptr(llmemory.WeakRef)
def rtype_simple_call(self, hop):
v_wref, = hop.inputargs(self)
@@ -59,6 +63,7 @@ class LLWeakRefRepr(BaseWeakRefRepr):
class OOWeakRefRepr(BaseWeakRefRepr):
lowleveltype = ootype.WeakReference
dead_wref = ootype.dead_wref
+ null_wref = ootype.null(ootype.WeakReference)
def rtype_simple_call(self, hop):
v_wref, = hop.inputargs(self)