Author: Armin Rigo <[email protected]>
Branch:
Changeset: r61320:95b58361ccf1
Date: 2013-02-16 12:19 +0100
http://bitbucket.org/pypy/pypy/changeset/95b58361ccf1/
Log: merge heads
diff --git a/pypy/interpreter/miscutils.py b/pypy/interpreter/miscutils.py
--- a/pypy/interpreter/miscutils.py
+++ b/pypy/interpreter/miscutils.py
@@ -20,10 +20,10 @@
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):
diff --git a/pypy/module/__pypy__/interp_signal.py
b/pypy/module/__pypy__/interp_signal.py
--- a/pypy/module/__pypy__/interp_signal.py
+++ b/pypy/module/__pypy__/interp_signal.py
@@ -1,6 +1,6 @@
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)
diff --git a/pypy/module/__pypy__/test/test_signal.py
b/pypy/module/__pypy__/test/test_signal.py
--- a/pypy/module/__pypy__/test/test_signal.py
+++ b/pypy/module/__pypy__/test/test_signal.py
@@ -3,18 +3,6 @@
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__'])
@@ -28,6 +16,14 @@
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
diff --git a/pypy/module/thread/threadlocals.py
b/pypy/module/thread/threadlocals.py
--- a/pypy/module/thread/threadlocals.py
+++ b/pypy/module/thread/threadlocals.py
@@ -1,4 +1,5 @@
from rpython.rlib import rthread
+from pypy.interpreter.error import OperationError
class OSThreadLocals:
@@ -54,14 +55,18 @@
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:
@@ -85,9 +90,11 @@
# 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
diff --git a/rpython/rlib/rstruct/ieee.py b/rpython/rlib/rstruct/ieee.py
--- a/rpython/rlib/rstruct/ieee.py
+++ b/rpython/rlib/rstruct/ieee.py
@@ -255,6 +255,7 @@
l.reverse()
result.append("".join(l))
[email protected]_safe
def unpack_float(s, be):
unsigned = r_ulonglong(0)
for i in range(min(len(s), 8)):
@@ -262,6 +263,7 @@
unsigned |= r_ulonglong(c) << (i * 8)
return float_unpack(unsigned, len(s))
[email protected]_safe
def unpack_float80(s, be):
QQ = [r_ulonglong(0), r_ulonglong(0)]
for i in range(8):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit