[pypy-commit] pypy default: fix: must be ready for the _pinned_objects list to contain both RPython and LL objects at the same time, for some tests
arigo
noreply at buildbot.pypy.org
Sat Oct 25 16:19:29 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r74220:9cd4ddc8935b
Date: 2014-10-25 16:19 +0200
http://bitbucket.org/pypy/pypy/changeset/9cd4ddc8935b/
Log: fix: must be ready for the _pinned_objects list to contain both
RPython and LL objects at the same time, for some tests
diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -20,8 +20,7 @@
# for test purposes we allow objects to be pinned and use
# the following list to keep track of the pinned objects
-if not we_are_translated():
- pinned_objects = []
+_pinned_objects = []
def pin(obj):
"""If 'obj' can move, then attempt to temporarily fix it. This
@@ -45,7 +44,7 @@
Note further that pinning an object does not prevent it from being
collected if it is not used anymore.
"""
- pinned_objects.append(obj)
+ _pinned_objects.append(obj)
return True
@@ -64,8 +63,13 @@
"""Unpin 'obj', allowing it to move again.
Must only be called after a call to pin(obj) returned True.
"""
- pinned_objects.remove(obj)
-
+ for i in range(len(_pinned_objects)):
+ try:
+ if _pinned_objects[i] == obj:
+ del _pinned_objects[i]
+ except TypeError:
+ pass
+
class UnpinEntry(ExtRegistryEntry):
_about_ = unpin
@@ -79,7 +83,14 @@
def _is_pinned(obj):
"""Method to check if 'obj' is pinned."""
- return obj in pinned_objects
+ for i in range(len(_pinned_objects)):
+ try:
+ if _pinned_objects[i] == obj:
+ return True
+ except TypeError:
+ pass
+ return False
+
class IsPinnedEntry(ExtRegistryEntry):
_about_ = _is_pinned
More information about the pypy-commit
mailing list