[pypy-commit] pypy stacklet: Rename the "continuation" class to "continulet".

arigo noreply at buildbot.pypy.org
Thu Aug 18 13:39:58 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: stacklet
Changeset: r46598:96757663e018
Date: 2011-08-18 13:44 +0200
http://bitbucket.org/pypy/pypy/changeset/96757663e018/

Log:	Rename the "continuation" class to "continulet". The module is still
	called "_continuation".

diff --git a/pypy/module/_continuation/__init__.py b/pypy/module/_continuation/__init__.py
--- a/pypy/module/_continuation/__init__.py
+++ b/pypy/module/_continuation/__init__.py
@@ -32,5 +32,5 @@
     }
 
     interpleveldefs = {
-        'continuation': 'interp_continuation.W_Continuation',
+        'continulet': 'interp_continuation.W_Continulet',
     }
diff --git a/pypy/module/_continuation/app_continuation.py b/pypy/module/_continuation/app_continuation.py
--- a/pypy/module/_continuation/app_continuation.py
+++ b/pypy/module/_continuation/app_continuation.py
@@ -18,7 +18,7 @@
         return genlet(self.__func__, *args, **kwds)
 
 
-class genlet(_continuation.continuation):
+class genlet(_continuation.continulet):
 
     def __iter__(self):
         return self
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
@@ -7,7 +7,7 @@
 from pypy.interpreter.gateway import interp2app
 
 
-class W_Continuation(Wrappable):
+class W_Continulet(Wrappable):
     sthread = None
 
     def __init__(self, space):
@@ -33,7 +33,7 @@
 
     def descr_init(self, w_callable, __args__):
         if self.sthread is not None:
-            raise geterror(self.space, "continuation already __init__ialized")
+            raise geterror(self.space, "continulet already __init__ialized")
         start_state.origin = self
         start_state.w_callable = w_callable
         start_state.args = __args__
@@ -49,9 +49,9 @@
 
     def descr_switch(self, w_value=None):
         if self.sthread is None:
-            raise geterror(self.space, "continuation not initialized yet")
+            raise geterror(self.space, "continulet not initialized yet")
         if self.sthread.is_empty_handle(self.h):
-            raise geterror(self.space, "continuation already finished")
+            raise geterror(self.space, "continulet already finished")
         ec = self.check_sthread()
         saved_topframeref = ec.topframeref
         start_state.w_value = w_value
@@ -76,19 +76,19 @@
         return self.space.newbool(valid)
 
 
-def W_Continuation___new__(space, w_subtype, __args__):
-    r = space.allocate_instance(W_Continuation, w_subtype)
+def W_Continulet___new__(space, w_subtype, __args__):
+    r = space.allocate_instance(W_Continulet, w_subtype)
     r.__init__(space)
     return space.wrap(r)
 
 
-W_Continuation.typedef = TypeDef(
-    'continuation',
+W_Continulet.typedef = TypeDef(
+    'continulet',
     __module__ = '_continuation',
-    __new__     = interp2app(W_Continuation___new__),
-    __init__    = interp2app(W_Continuation.descr_init),
-    switch      = interp2app(W_Continuation.descr_switch),
-    is_pending  = interp2app(W_Continuation.descr_is_pending),
+    __new__     = interp2app(W_Continulet___new__),
+    __init__    = interp2app(W_Continulet.descr_init),
+    switch      = interp2app(W_Continulet.descr_switch),
+    is_pending  = interp2app(W_Continulet.descr_is_pending),
     )
 
 
@@ -157,7 +157,7 @@
             return self.h    # just propagate it further
         if start_state.w_value is not space.w_None:
             raise OperationError(space.w_TypeError, space.wrap(
-                "can't send non-None value to a just-started continuation"))
+                "can't send non-None value to a just-started continulet"))
 
         args = args.prepend(space.wrap(self))
         w_result = space.call_args(w_callable, args)
diff --git a/pypy/module/_continuation/test/test_stacklet.py b/pypy/module/_continuation/test/test_stacklet.py
--- a/pypy/module/_continuation/test/test_stacklet.py
+++ b/pypy/module/_continuation/test/test_stacklet.py
@@ -10,16 +10,16 @@
                          'test_translated.py'))
 
     def test_new_empty(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def empty_callback(c):
             pass
         #
-        c = continuation(empty_callback)
-        assert type(c) is continuation
+        c = continulet(empty_callback)
+        assert type(c) is continulet
 
     def test_call_empty(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def empty_callback(c1):
             assert c1 is c
@@ -27,44 +27,44 @@
             return 42
         #
         seen = []
-        c = continuation(empty_callback)
+        c = continulet(empty_callback)
         res = c.switch()
         assert res == 42
         assert seen == [1]
 
     def test_no_double_init(self):
-        from _continuation import continuation, error
+        from _continuation import continulet, error
         #
         def empty_callback(c1):
             pass
         #
-        c = continuation(empty_callback)
+        c = continulet(empty_callback)
         raises(error, c.__init__, empty_callback)
 
     def test_no_init_after_started(self):
-        from _continuation import continuation, error
+        from _continuation import continulet, error
         #
         def empty_callback(c1):
             raises(error, c1.__init__, empty_callback)
             return 42
         #
-        c = continuation(empty_callback)
+        c = continulet(empty_callback)
         res = c.switch()
         assert res == 42
 
     def test_no_init_after_finished(self):
-        from _continuation import continuation, error
+        from _continuation import continulet, error
         #
         def empty_callback(c1):
             return 42
         #
-        c = continuation(empty_callback)
+        c = continulet(empty_callback)
         res = c.switch()
         assert res == 42
         raises(error, c.__init__, empty_callback)
 
     def test_propagate_exception(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def empty_callback(c1):
             assert c1 is c
@@ -72,12 +72,12 @@
             raise ValueError
         #
         seen = []
-        c = continuation(empty_callback)
+        c = continulet(empty_callback)
         raises(ValueError, c.switch)
         assert seen == [42]
 
     def test_callback_with_arguments(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def empty_callback(c1, *args, **kwds):
             seen.append(c1)
@@ -86,13 +86,13 @@
             return 42
         #
         seen = []
-        c = continuation(empty_callback, 42, 43, foo=44, bar=45)
+        c = continulet(empty_callback, 42, 43, foo=44, bar=45)
         res = c.switch()
         assert res == 42
         assert seen == [c, (42, 43), {'foo': 44, 'bar': 45}]
 
     def test_switch(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def switchbackonce_callback(c):
             seen.append(1)
@@ -102,7 +102,7 @@
             return 'c'
         #
         seen = []
-        c = continuation(switchbackonce_callback)
+        c = continulet(switchbackonce_callback)
         seen.append(0)
         res = c.switch()
         assert res == 'a'
@@ -112,37 +112,37 @@
         assert seen == [0, 1, 2, 3]
 
     def test_initial_switch_must_give_None(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def empty_callback(c):
             return 'ok'
         #
-        c = continuation(empty_callback)
+        c = continulet(empty_callback)
         res = c.switch(None)
         assert res == 'ok'
         #
-        c = continuation(empty_callback)
+        c = continulet(empty_callback)
         raises(TypeError, c.switch, 'foo')  # "can't send non-None value"
 
     def test_continuation_error(self):
-        from _continuation import continuation, error
+        from _continuation import continulet, error
         #
         def empty_callback(c):
             return 42
         #
-        c = continuation(empty_callback)
+        c = continulet(empty_callback)
         c.switch()
         e = raises(error, c.switch)
-        assert str(e.value) == "continuation already finished"
+        assert str(e.value) == "continulet already finished"
 
     def test_not_initialized_yet(self):
-        from _continuation import continuation, error
-        c = continuation.__new__(continuation)
+        from _continuation import continulet, error
+        c = continulet.__new__(continulet)
         e = raises(error, c.switch)
-        assert str(e.value) == "continuation not initialized yet"
+        assert str(e.value) == "continulet not initialized yet"
 
     def test_go_depth2(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def depth2(c):
             seen.append(3)
@@ -150,21 +150,21 @@
         #
         def depth1(c):
             seen.append(1)
-            c2 = continuation(depth2)
+            c2 = continulet(depth2)
             seen.append(2)
             res = c2.switch()
             seen.append(res)
             return 5
         #
         seen = []
-        c = continuation(depth1)
+        c = continulet(depth1)
         seen.append(0)
         res = c.switch()
         seen.append(res)
         assert seen == [0, 1, 2, 3, 4, 5]
 
     def test_exception_depth2(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def depth2(c):
             seen.append(2)
@@ -173,19 +173,19 @@
         def depth1(c):
             seen.append(1)
             try:
-                continuation(depth2).switch()
+                continulet(depth2).switch()
             except ValueError:
                 seen.append(3)
             return 4
         #
         seen = []
-        c = continuation(depth1)
+        c = continulet(depth1)
         res = c.switch()
         seen.append(res)
         assert seen == [1, 2, 3, 4]
 
     def test_exception_with_switch(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def depth1(c):
             seen.append(1)
@@ -194,7 +194,7 @@
             raise ValueError
         #
         seen = []
-        c = continuation(depth1)
+        c = continulet(depth1)
         seen.append(0)
         c.switch()
         seen.append(2)
@@ -202,7 +202,7 @@
         assert seen == [0, 1, 2, 3]
 
     def test_is_pending(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def switchbackonce_callback(c):
             assert c.is_pending()
@@ -211,7 +211,7 @@
             assert c.is_pending()
             return 'c'
         #
-        c = continuation.__new__(continuation)
+        c = continulet.__new__(continulet)
         assert not c.is_pending()
         c.__init__(switchbackonce_callback)
         assert c.is_pending()
@@ -223,7 +223,7 @@
         assert not c.is_pending()
 
     def test_switch_alternate(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def func_lower(c):
             res = c.switch('a')
@@ -239,8 +239,8 @@
             assert res == 'D'
             return 'E'
         #
-        c_lower = continuation(func_lower)
-        c_upper = continuation(func_upper)
+        c_lower = continulet(func_lower)
+        c_upper = continulet(func_upper)
         res = c_lower.switch()
         assert res == 'a'
         res = c_upper.switch()
@@ -255,7 +255,7 @@
         assert res == 'E'
 
     def test_exception_with_switch_depth2(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def depth2(c):
             seen.append(4)
@@ -267,7 +267,7 @@
             seen.append(1)
             c.switch()
             seen.append(3)
-            c2 = continuation(depth2)
+            c2 = continulet(depth2)
             c2.switch()
             seen.append(5)
             raises(ValueError, c2.switch)
@@ -277,7 +277,7 @@
             raise KeyError
         #
         seen = []
-        c = continuation(depth1)
+        c = continulet(depth1)
         c.switch()
         seen.append(2)
         raises(KeyError, c.switch)
@@ -285,7 +285,7 @@
         assert seen == [1, 2, 3, 4, 5, 6, 7]
 
     def test_random_switching(self):
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def t1(c1):
             return c1.switch()
@@ -300,8 +300,8 @@
             return c2.switch('b') + 2
         #
         def f():
-            c1 = continuation(s1, 123)
-            c2 = continuation(s2, c1)
+            c1 = continulet(s1, 123)
+            c2 = continulet(s2, c1)
             c1.switch()
             res = c2.switch()
             assert res == 'b'
@@ -314,7 +314,7 @@
 
     def test_f_back_is_None_for_now(self):
         import sys
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def g(c):
             c.switch(sys._getframe(0))
@@ -325,7 +325,7 @@
         def f(c):
             g(c)
         #
-        c = continuation(f)
+        c = continulet(f)
         f1 = c.switch()
         assert f1.f_code.co_name == 'g'
         f2 = c.switch()
@@ -338,7 +338,7 @@
 
     def test_traceback_is_complete(self):
         import sys
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def g():
             raise KeyError
@@ -348,7 +348,7 @@
         def do(c):
             c.switch()
         #
-        c = continuation(f)
+        c = continulet(f)
         try:
             do(c)
         except KeyError:
@@ -363,7 +363,7 @@
 
     def test_switch2_simple(self):
         skip("in-progress")
-        from _continuation import continuation
+        from _continuation import continulet
         #
         def f1(c1):
             res = c1.switch_to(c2)
@@ -373,8 +373,8 @@
             c2.switch_to(c1, 'a')
             return 42
         #
-        c1 = continuation(f1)
-        c2 = continuation(f2)
+        c1 = continulet(f1)
+        c2 = continulet(f2)
         res = c1.switch()
         assert res == 41
         assert c2.is_pending()    # already


More information about the pypy-commit mailing list