Commit effc3393 authored by Barry Warsaw's avatar Barry Warsaw

gcReferences(): Tim rightly points out that we shouldn't be filtering

out duplicate oids.  If a pickle holds multiple references to an
object, that object's oids will show up multiple times in the returned
list.
parent 3624097a
...@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support ...@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning. undo or versioning.
""" """
# $Revision: 1.17 $ # $Revision: 1.18 $
__version__ = '0.1' __version__ = '0.1'
import struct import struct
...@@ -994,7 +994,7 @@ class Full(BerkeleyBase): ...@@ -994,7 +994,7 @@ class Full(BerkeleyBase):
Raises KeyError if there is no object with oid. The oid argument Raises KeyError if there is no object with oid. The oid argument
is an integer; the return value is a list of integers of oids. is an integer; the return value is a list of integers of oids.
""" """
oids = {} oids = []
c = None c = None
self._lock_acquire() self._lock_acquire()
try: try:
...@@ -1007,10 +1007,10 @@ class Full(BerkeleyBase): ...@@ -1007,10 +1007,10 @@ class Full(BerkeleyBase):
# Sniff the pickle for object references # Sniff the pickle for object references
tmpoids = [] tmpoids = []
referencesf(pickle, tmpoids) referencesf(pickle, tmpoids)
# Convert to unsigned longs
oids.extend(map(utils.U64, tmpoids))
# Make sure there's no duplicates, and convert to int # Make sure there's no duplicates, and convert to int
for oid in tmpoids: return oids
oids[utils.U64(oid)] = 1
return oids.keys()
finally: finally:
if c: if c:
c.close() c.close()
......
...@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support ...@@ -4,7 +4,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning. undo or versioning.
""" """
# $Revision: 1.17 $ # $Revision: 1.18 $
__version__ = '0.1' __version__ = '0.1'
import struct import struct
...@@ -994,7 +994,7 @@ class Full(BerkeleyBase): ...@@ -994,7 +994,7 @@ class Full(BerkeleyBase):
Raises KeyError if there is no object with oid. The oid argument Raises KeyError if there is no object with oid. The oid argument
is an integer; the return value is a list of integers of oids. is an integer; the return value is a list of integers of oids.
""" """
oids = {} oids = []
c = None c = None
self._lock_acquire() self._lock_acquire()
try: try:
...@@ -1007,10 +1007,10 @@ class Full(BerkeleyBase): ...@@ -1007,10 +1007,10 @@ class Full(BerkeleyBase):
# Sniff the pickle for object references # Sniff the pickle for object references
tmpoids = [] tmpoids = []
referencesf(pickle, tmpoids) referencesf(pickle, tmpoids)
# Convert to unsigned longs
oids.extend(map(utils.U64, tmpoids))
# Make sure there's no duplicates, and convert to int # Make sure there's no duplicates, and convert to int
for oid in tmpoids: return oids
oids[utils.U64(oid)] = 1
return oids.keys()
finally: finally:
if c: if c:
c.close() c.close()
......
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