Patchwork [3,of,5,STABLE] crecord: avoid setting non-existing signal SIGWINCH on windows

login
register
mail settings
Submitter Pierre-Yves David
Date April 12, 2017, 8:41 a.m.
Message ID <7c33ce6b8a6991d4189c.1491986478@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20130/
State Accepted
Headers show

Comments

Pierre-Yves David - April 12, 2017, 8:41 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1491470733 -7200
#      Thu Apr 06 11:25:33 2017 +0200
# Branch stable
# Node ID 7c33ce6b8a6991d4189c7d379a78a2c2fa802c35
# Parent  85d5c3551f2b44399418e00fd62630344694ed1c
# EXP-Topic crecord-windows
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 7c33ce6b8a69
crecord: avoid setting non-existing signal SIGWINCH on windows

Windows do not have a SIGWINCH so we avoid setting the handler if the signal is
unknown.

Patch

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -1611,12 +1611,15 @@  are you sure you want to review/edit and
         method to be wrapped by curses.wrapper() for selecting chunks.
         """
 
-        origsigwinchhandler = signal.signal(signal.SIGWINCH,
-                                            self.sigwinchhandler)
+        origsigwinch = sentinel = object()
+        if util.safehasattr(signal, 'SIGWINCH'):
+            origsigwinch = signal.signal(signal.SIGWINCH,
+                                         self.sigwinchhandler)
         try:
             return self._main(stdscr)
         finally:
-            signal.signal(signal.SIGWINCH, origsigwinchhandler)
+            if origsigwinch is not sentinel:
+                signal.signal(signal.SIGWINCH, origsigwinch)
 
     def _main(self, stdscr):
         self.stdscr = stdscr