Author: Stefan Beyer <[email protected]>
Branch: cpyext-gc-cycle
Changeset: r96525:31150aa29431
Date: 2019-04-20 14:29 +0200
http://bitbucket.org/pypy/pypy/changeset/31150aa29431/
Log: Improved weakref support for rawrefcount dot tests and added test
diff --git a/rpython/memory/gc/test/dot/free_cpython_weakref_multi.dot
b/rpython/memory/gc/test/dot/free_cpython_weakref_multi_1.dot
rename from rpython/memory/gc/test/dot/free_cpython_weakref_multi.dot
rename to rpython/memory/gc/test/dot/free_cpython_weakref_multi_1.dot
diff --git a/rpython/memory/gc/test/dot/free_cpython_weakref_multi.dot
b/rpython/memory/gc/test/dot/free_cpython_weakref_multi_2.dot
copy from rpython/memory/gc/test/dot/free_cpython_weakref_multi.dot
copy to rpython/memory/gc/test/dot/free_cpython_weakref_multi_2.dot
--- a/rpython/memory/gc/test/dot/free_cpython_weakref_multi.dot
+++ b/rpython/memory/gc/test/dot/free_cpython_weakref_multi_2.dot
@@ -4,5 +4,5 @@
"a" -> "b";
"b" -> "a";
"a" -> "b" [weakref=y, callback=y, clear_callback=y];
- "b" -> "a" [weakref=y, callback=y, clear_callback=y];
+ "a" -> "b" [weakref=y, callback=y, clear_callback=y];
}
diff --git a/rpython/memory/gc/test/test_rawrefcount.py
b/rpython/memory/gc/test/test_rawrefcount.py
--- a/rpython/memory/gc/test/test_rawrefcount.py
+++ b/rpython/memory/gc/test/test_rawrefcount.py
@@ -598,6 +598,7 @@
# quick self check, if traverse works properly
dests_by_source = {}
+ weakrefs_added = []
for e in g.get_edges():
source = nodes[e.get_source()]
dest = nodes[e.get_destination()]
@@ -607,9 +608,11 @@
if not dests_by_source.has_key(source):
dests_by_source[source] = []
if weakref:
- wrs = self.pyobj_weakrefs[self.pyobjs.index(source.r)]
- # currently only one weakref supported
- dests_by_source[source].append(wrs[0].r)
+ if source not in weakrefs_added: # add all weakrefs at once
+ weakrefs_added.append(source)
+ wrs = self.pyobj_weakrefs[self.pyobjs.index(source.r)]
+ for wr in wrs:
+ dests_by_source[source].append(wr.r)
else:
dests_by_source[source].append(dest.r)
for source in dests_by_source:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit