# HG changeset patch # User Pierre-Yves David # Date 2017-04-06 09:28:25 # Node ID b2478a996a820c3f98f991adfcd2623cedc03c18 # Parent 20a68f714f9b1fee88b5992ca62064db1dd4eb58 crecord: avoid setting non-existing SIGTSTP signal on windows (issue5512) Windows do not have a SIGTSTP so we avoid setting the handler if the signal is unknown. diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -473,14 +473,17 @@ def chunkselector(ui, headerlist, operat """ ui.write(_('starting interactive selection\n')) chunkselector = curseschunkselector(headerlist, ui, operation) - f = signal.getsignal(signal.SIGTSTP) + origsigtstp = sentinel = object() + if util.safehasattr(signal, 'SIGTSTP'): + origsigtstp = signal.getsignal(signal.SIGTSTP) try: curses.wrapper(chunkselector.main) if chunkselector.initerr is not None: raise error.Abort(chunkselector.initerr) # ncurses does not restore signal handler for SIGTSTP finally: - signal.signal(signal.SIGTSTP, f) + if origsigtstp is not sentinel: + signal.signal(signal.SIGTSTP, origsigtstp) return chunkselector.opts def testdecorator(testfn, f):