[pypy-svn] r56135 - in pypy/branch/async-del/pypy: interpreter module/signal

arigo at codespeak.net arigo at codespeak.net
Fri Jun 27 19:47:55 CEST 2008


Author: arigo
Date: Fri Jun 27 19:47:54 2008
New Revision: 56135

Modified:
   pypy/branch/async-del/pypy/interpreter/executioncontext.py
   pypy/branch/async-del/pypy/module/signal/__init__.py
   pypy/branch/async-del/pypy/module/signal/interp_signal.py
Log:
Translation fix.


Modified: pypy/branch/async-del/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/branch/async-del/pypy/interpreter/executioncontext.py	(original)
+++ pypy/branch/async-del/pypy/interpreter/executioncontext.py	Fri Jun 27 19:47:54 2008
@@ -241,7 +241,7 @@
                         " traceback and see where this one comes from :-)")
 
 
-class ActionFlag:
+class AbstractActionFlag:
     """This holds the global 'action flag'.  It is a single bitfield
     integer, with bits corresponding to AsyncAction objects that need to
     be immediately triggered.  The correspondance from bits to
@@ -252,7 +252,6 @@
     when to release the GIL.
     """
     def __init__(self):
-        self.__flags = 0
         self._periodic_actions = []
         self._nonperiodic_actions = []
         self.unused_bits = self.FREE_BITS[:]
@@ -260,15 +259,6 @@
         self.interesting_bits = 0
         self._rebuild_action_dispatcher()
 
-    # '__flags' is "very private" -- don't access it even from elsewhere
-    # in this class.  The get()/set() accessors are meant to be overriden
-    # by the signal module, if it is used.
-    def get(self):
-        return self.__flags
-
-    def set(self, value):
-        self.__flags = value
-
     def fire(self, action):
         """Request for the action to be run before the next opcode.
         The action must have been registered at space initalization time."""
@@ -351,6 +341,18 @@
     CHECK_INTERVAL_MAX = BYTECODE_COUNTER_OVERFLOW_BIT
 
 
+class ActionFlag(AbstractActionFlag):
+    """The normal class for space.actionflag.  The signal module provides
+    a different one."""
+    _flags = 0
+
+    def get(self):
+        return self._flags
+
+    def set(self, value):
+        self._flags = value
+
+
 class AsyncAction(object):
     """Abstract base class for actions that must be performed
     asynchronously with regular bytecode execution, but that still need

Modified: pypy/branch/async-del/pypy/module/signal/__init__.py
==============================================================================
--- pypy/branch/async-del/pypy/module/signal/__init__.py	(original)
+++ pypy/branch/async-del/pypy/module/signal/__init__.py	Fri Jun 27 19:47:54 2008
@@ -33,5 +33,5 @@
         # use the C-level pypysig_occurred variable as the action flag
         # (the result is that the C-level signal handler will directly
         # set the flag for the CheckSignalAction)
-        space.actionflag.get = interp_signal.pypysig_get_occurred
-        space.actionflag.set = interp_signal.pypysig_set_occurred
+        space.actionflag.__class__ = interp_signal.SignalActionFlag
+        # xxx yes I know the previous line is a hack

Modified: pypy/branch/async-del/pypy/module/signal/interp_signal.py
==============================================================================
--- pypy/branch/async-del/pypy/module/signal/interp_signal.py	(original)
+++ pypy/branch/async-del/pypy/module/signal/interp_signal.py	Fri Jun 27 19:47:54 2008
@@ -1,6 +1,6 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.baseobjspace import W_Root, ObjSpace
-from pypy.interpreter.executioncontext import AsyncAction
+from pypy.interpreter.executioncontext import AsyncAction, AbstractActionFlag
 from pypy.rlib.rarithmetic import LONG_BIT, intmask
 import signal as cpy_signal
 from pypy.rpython.lltypesystem import lltype, rffi
@@ -41,6 +41,12 @@
 pypysig_set_occurred = external('pypysig_set_occurred', [lltype.Signed],
                                 lltype.Void, _nowrapper=True)
 
+
+class SignalActionFlag(AbstractActionFlag):
+    get = staticmethod(pypysig_get_occurred)
+    set = staticmethod(pypysig_set_occurred)
+
+
 class CheckSignalAction(AsyncAction):
     """An action that is automatically invoked when a signal is received."""
 



More information about the Pypy-commit mailing list