Author: Antonio Cuni <[email protected]>
Branch: gc-disable
Changeset: r94682:91902e174491
Date: 2018-05-24 15:01 +0200
http://bitbucket.org/pypy/pypy/changeset/91902e174491/
Log: the app-level gc.{enable,disable} now call also the rgc equivalent,
to actually disable major collections
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
@@ -39,18 +39,20 @@
return space.newint(0)
def enable(space):
- """Non-recursive version. Enable finalizers now.
+ """Non-recursive version. Enable major collections and finalizers.
If they were already enabled, no-op.
If they were disabled even several times, enable them anyway.
"""
+ rgc.enable()
if not space.user_del_action.enabled_at_app_level:
space.user_del_action.enabled_at_app_level = True
enable_finalizers(space)
def disable(space):
- """Non-recursive version. Disable finalizers now. Several calls
- to this function are ignored.
+ """Non-recursive version. Disable major collections and finalizers.
+ Multiple calls to this function are ignored.
"""
+ rgc.disable()
if space.user_del_action.enabled_at_app_level:
space.user_del_action.enabled_at_app_level = False
disable_finalizers(space)
diff --git a/pypy/module/gc/test/test_gc.py b/pypy/module/gc/test/test_gc.py
--- a/pypy/module/gc/test/test_gc.py
+++ b/pypy/module/gc/test/test_gc.py
@@ -1,7 +1,19 @@
import py
-
+import pytest
+from rpython.rlib import rgc
+from pypy.interpreter.baseobjspace import ObjSpace
+from pypy.interpreter.gateway import interp2app, unwrap_spec
class AppTestGC(object):
+
+ def setup_class(cls):
+ if cls.runappdirect:
+ pytest.skip("these tests cannot work with -A")
+ space = cls.space
+ def rgc_isenabled(space):
+ return space.newbool(rgc.isenabled())
+ cls.w_rgc_isenabled = space.wrap(interp2app(rgc_isenabled))
+
def test_collect(self):
import gc
gc.collect() # mostly a "does not crash" kind of test
@@ -63,12 +75,16 @@
def test_enable(self):
import gc
assert gc.isenabled()
+ assert self.rgc_isenabled()
gc.disable()
assert not gc.isenabled()
+ assert not self.rgc_isenabled()
gc.enable()
assert gc.isenabled()
+ assert self.rgc_isenabled()
gc.enable()
assert gc.isenabled()
+ assert self.rgc_isenabled()
def test_gc_collect_overrides_gc_disable(self):
import gc
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit