Author: Brian Kearns <[email protected]>
Branch: 
Changeset: r231:a0a7573023f0
Date: 2013-02-24 17:03 -0500
http://bitbucket.org/pypy/pyrepl/changeset/a0a7573023f0/

Log:    ensure unix_console.{prepare,restore} maintain state properly for
        when signal fails (ie in a thread), test

diff --git a/pyrepl/unix_console.py b/pyrepl/unix_console.py
--- a/pyrepl/unix_console.py
+++ b/pyrepl/unix_console.py
@@ -393,6 +393,7 @@
 
         if hasattr(self, 'old_sigwinch'):
             signal.signal(signal.SIGWINCH, self.old_sigwinch)
+            del self.old_sigwinch
 
     def __sigwinch(self, signum, frame):
         self.height, self.width = self.getheightwidth()
diff --git a/testing/test_bugs.py b/testing/test_bugs.py
--- a/testing/test_bugs.py
+++ b/testing/test_bugs.py
@@ -44,3 +44,29 @@
         ('accept', [''])
     ]
     read_spec(spec, HistoricalTestReader)
+
+
+def test_signal_failure(monkeypatch):
+    import os
+    import pty
+    import signal
+    from pyrepl.unix_console import UnixConsole
+
+    def failing_signal(a, b):
+        raise ValueError
+
+    def really_failing_signal(a, b):
+        raise AssertionError
+
+    mfd, sfd = pty.openpty()
+    try:
+        c = UnixConsole(sfd, sfd)
+        c.prepare()
+        c.restore()
+        monkeypatch.setattr(signal, 'signal', failing_signal)
+        c.prepare()
+        monkeypatch.setattr(signal, 'signal', really_failing_signal)
+        c.restore()
+    finally:
+        os.close(mfd)
+        os.close(sfd)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to