Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r81681:beb301687f9b
Date: 2016-01-12 09:27 +0100
http://bitbucket.org/pypy/pypy/changeset/beb301687f9b/

Log:    Remove the need for passing "config" to StackletThread().

diff --git a/pypy/module/_continuation/interp_continuation.py 
b/pypy/module/_continuation/interp_continuation.py
--- a/pypy/module/_continuation/interp_continuation.py
+++ b/pypy/module/_continuation/interp_continuation.py
@@ -195,7 +195,7 @@
 class SThread(StackletThread):
 
     def __init__(self, space, ec):
-        StackletThread.__init__(self, space.config)
+        StackletThread.__init__(self)
         self.space = space
         self.ec = ec
         # for unpickling
diff --git a/rpython/rlib/rstacklet.py b/rpython/rlib/rstacklet.py
--- a/rpython/rlib/rstacklet.py
+++ b/rpython/rlib/rstacklet.py
@@ -1,7 +1,7 @@
 import sys
 from rpython.rlib import _rffi_stacklet as _c
 from rpython.rlib import jit
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import fetch_translated_config
 from rpython.rtyper.lltypesystem import lltype, llmemory
 
 DEBUG = False
@@ -10,8 +10,8 @@
 class StackletThread(object):
 
     @jit.dont_look_inside
-    def __init__(self, config):
-        self._gcrootfinder = _getgcrootfinder(config, we_are_translated())
+    def __init__(self, _argument_ignored_for_backward_compatibility=None):
+        self._gcrootfinder = _getgcrootfinder(fetch_translated_config())
         self._thrd = _c.newthread()
         if not self._thrd:
             raise MemoryError
@@ -67,11 +67,8 @@
 
 # ____________________________________________________________
 
-def _getgcrootfinder(config, translated):
-    if translated:
-        assert config is not None, ("you have to pass a valid config, "
-                                    "e.g. from 'driver.config'")
-    elif '__pypy__' in sys.builtin_module_names:
+def _getgcrootfinder(config):
+    if config is None and '__pypy__' in sys.builtin_module_names:
         import py
         py.test.skip("cannot run the stacklet tests on top of pypy: "
                      "calling directly the C function stacklet_switch() "
diff --git a/rpython/rlib/test/test_rstacklet.py 
b/rpython/rlib/test/test_rstacklet.py
--- a/rpython/rlib/test/test_rstacklet.py
+++ b/rpython/rlib/test/test_rstacklet.py
@@ -17,10 +17,9 @@
 
 class Runner:
     STATUSMAX = 5000
-    config = None
 
     def init(self, seed):
-        self.sthread = rstacklet.StackletThread(self.config)
+        self.sthread = rstacklet.StackletThread()
         self.random = rrandom.Random(seed)
 
     def done(self):
@@ -301,12 +300,11 @@
             config.translation.gcrootfinder = cls.gcrootfinder
             GCROOTFINDER = cls.gcrootfinder
         cls.config = config
-        cls.old_values = Runner.config, Runner.STATUSMAX
-        Runner.config = config
+        cls.old_status_max = Runner.STATUSMAX
         Runner.STATUSMAX = 25000
 
     def teardown_class(cls):
-        Runner.config, Runner.STATUSMAX = cls.old_values
+        Runner.STATUSMAX = cls.old_status_max
 
     def test_demo1(self):
         t, cbuilder = self.compile(entry_point)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to