Commits

Armin Rigo committed 95b5836 Merge

merge heads

  • Participants
  • Parent commits e7bbbe5, 46b7094

Comments (0)

Files changed (5)

File pypy/interpreter/miscutils.py

     def signals_enabled(self):
         return True
 
-    def enable_signals(self):
+    def enable_signals(self, space):
         pass
 
-    def disable_signals(self):
+    def disable_signals(self, space):
         pass
 
     def getallvalues(self):

File pypy/module/__pypy__/interp_signal.py

 
 def signals_enter(space):
-    space.threadlocals.enable_signals()
+    space.threadlocals.enable_signals(space)
 
 def signals_exit(space, w_ignored1=None, w_ignored2=None, w_ignored3=None):
-    space.threadlocals.disable_signals()
+    space.threadlocals.disable_signals(space)

File pypy/module/__pypy__/test/test_signal.py

 from pypy.module.thread.test.support import GenericTestThread
 
 
-class TestThreadSignal:
-    spaceconfig = dict(usemodules=['__pypy__', 'thread'])
-
-    def test_exit_twice(self, space):
-        from pypy.module.__pypy__.interp_signal import signals_exit, signals_enter
-        signals_exit(space)
-        try:
-            raises(KeyError, signals_exit, space)
-        finally:
-            signals_enter(space)
-
-
 class AppTestMinimal:
     spaceconfig = dict(usemodules=['__pypy__'])
 
 class AppTestThreadSignal(GenericTestThread):
     spaceconfig = dict(usemodules=['__pypy__', 'thread', 'signal', 'time'])
 
+    def test_exit_twice(self):
+        from __pypy__ import thread
+        thread._signals_exit()
+        try:
+            raises(KeyError, thread._signals_exit)
+        finally:
+            thread._signals_enter()
+
     def test_enable_signals(self):
         import __pypy__, thread, signal, time
 

File pypy/module/thread/threadlocals.py

 from rpython.rlib import rthread
+from pypy.interpreter.error import OperationError
 
 
 class OSThreadLocals:
     def signals_enabled(self):
         return rthread.get_ident() in self._signalsenabled
 
-    def enable_signals(self):
+    def enable_signals(self, space):
         ident = rthread.get_ident()
         old = self._signalsenabled.get(ident, 0)
         self._signalsenabled[ident] = old + 1
 
-    def disable_signals(self):
+    def disable_signals(self, space):
         ident = rthread.get_ident()
-        new = self._signalsenabled[ident] - 1
+        try:
+            new = self._signalsenabled[ident] - 1
+        except KeyError:
+            raise OperationError(space.w_KeyError, space.wrap(
+                "cannot disable signals in thread not enabled for signals"))
         if new > 0:
             self._signalsenabled[ident] = new
         else:
         # enable_signals() if necessary.  That's a hack but I cannot
         # figure out a non-hackish way to handle thread+signal+fork :-(
         ident = rthread.get_ident()
-        old = self._signalsenabled.get(ident, 0)
-        if ident is not self._mainthreadident:
-            self._mainthreadident = ident
-            old += 1
-        self._signalsenabled.clear()
-        self._signalsenabled[ident] = old
+        val = self.getvalue()
+        sig = self._signalsenabled.get(ident, 0)
+        if ident != self._mainthreadident:
+            sig += 1
+        self._cleanup_()
+        self.setvalue(val)
+        self._signalsenabled[ident] = sig
+        self._mainthreadident = ident

File rpython/rlib/rstruct/ieee.py

         l.reverse()
     result.append("".join(l))
 
+@jit.unroll_safe
 def unpack_float(s, be):
     unsigned = r_ulonglong(0)
     for i in range(min(len(s), 8)):
         unsigned |= r_ulonglong(c) << (i * 8)
     return float_unpack(unsigned, len(s))
 
+@jit.unroll_safe
 def unpack_float80(s, be):
     QQ = [r_ulonglong(0), r_ulonglong(0)]
     for i in range(8):