Commits

Brian Kearns committed 04926eb

prevent signals from being disabled twice

Comments (0)

Files changed (2)

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__'])
 

pypy/module/thread/threadlocals.py

 
     def disable_signals(self):
         ident = rthread.get_ident()
-        try:
-            new = self._signalsenabled[ident] - 1
-        except KeyError:
-            return
+        new = self._signalsenabled[ident] - 1
         if new > 0:
             self._signalsenabled[ident] = new
         else: