Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r88794:2aa7dea5ad0f
Date: 2016-12-01 17:21 +0100
http://bitbucket.org/pypy/pypy/changeset/2aa7dea5ad0f/

Log:    Tweak gc.collect() when gc.disable() was called, see comment

diff --git a/pypy/module/gc/interp_gc.py b/pypy/module/gc/interp_gc.py
--- a/pypy/module/gc/interp_gc.py
+++ b/pypy/module/gc/interp_gc.py
@@ -14,7 +14,19 @@
     cache.clear()
     cache = space.fromcache(MapAttrCache)
     cache.clear()
+
     rgc.collect()
+
+    # if we are running in gc.disable() mode but gc.collect() is called,
+    # we should still call the finalizers now.  We do this as an attempt
+    # to get closer to CPython's behavior: in Py3.5 some tests
+    # specifically rely on that.  This is similar to how, in CPython, an
+    # explicit gc.collect() will invoke finalizers from cycles and fully
+    # ignore the gc.disable() mode.
+    if not space.user_del_action.enabled_at_app_level:
+        enable_finalizers(space)
+        disable_finalizers(space)
+
     return space.wrap(0)
 
 def enable(space):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to