[pypy-svn] r46464 - pypy/dist/pypy/rpython/lltypesystem
arigo at codespeak.net
arigo at codespeak.net
Tue Sep 11 12:14:49 CEST 2007
Author: arigo
Date: Tue Sep 11 12:14:48 2007
New Revision: 46464
Modified:
pypy/dist/pypy/rpython/lltypesystem/llmemory.py
Log:
For compatibility with existing code and tests all around the place,
re-emulate the previous interface about 'ref'.
Modified: pypy/dist/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/llmemory.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/llmemory.py Tue Sep 11 12:14:48 2007
@@ -496,7 +496,8 @@
if ob is not None:
if isinstance(ob, lltype._ptr):
ob = lltype.normalizeptr(ob)._obj
- self.ref = weakref.ref(ob)
+ self.obref = weakref.ref(ob)
+ self.ref = self.get # backward compatibility
# umpf
from pypy.rpython.memory import lltypesimulation
if isinstance(ob, (lltype._ptr,lltypesimulation.simulatorptr)):
@@ -504,11 +505,12 @@
else:
self.id = id(ob)
else:
+ self.obref = None
self.ref = None
def get(self):
- if self.ref is None:
+ if self.obref is None:
return None
- ob = self.ref()
+ ob = self.obref()
# xxx stop-gap
#if ob is None:
# raise DanglingPointerError
@@ -516,10 +518,10 @@
ob = ob._as_ptr()
return ob
def __repr__(self):
- if self.ref is None:
+ if self.obref is None:
s = 'NULL'
else:
- s = str(self.ref)
+ s = str(self.obref)
return '<%s %s>' % (self.__class__.__name__, s)
def cast_to_int(self):
# this is not always the behaviour that is really happening
More information about the Pypy-commit
mailing list