Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 50925:d718eddf01d9
safehasattr: drop usage in favor of hasattr
The two functions should now be equivalent at least in their usage in core.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 31 Aug 2023 23:56:15 +0200 |
parents | 29ce50726ce0 |
children | 18c8c18993f0 |
comparison
equal
deleted
inserted
replaced
50924:7a8ea1397816 | 50925:d718eddf01d9 |
---|---|
1465 b'starting pager for command %s\n' % stringutil.pprint(command) | 1465 b'starting pager for command %s\n' % stringutil.pprint(command) |
1466 ) | 1466 ) |
1467 self.flush() | 1467 self.flush() |
1468 | 1468 |
1469 wasformatted = self.formatted() | 1469 wasformatted = self.formatted() |
1470 if util.safehasattr(signal, "SIGPIPE"): | 1470 if hasattr(signal, "SIGPIPE"): |
1471 signal.signal(signal.SIGPIPE, _catchterm) | 1471 signal.signal(signal.SIGPIPE, _catchterm) |
1472 if self._runpager(pagercmd, pagerenv): | 1472 if self._runpager(pagercmd, pagerenv): |
1473 self.pageractive = True | 1473 self.pageractive = True |
1474 # Preserve the formatted-ness of the UI. This is important | 1474 # Preserve the formatted-ness of the UI. This is important |
1475 # because we mess with stdout, which might confuse | 1475 # because we mess with stdout, which might confuse |
1545 if self._isatty(procutil.stderr): | 1545 if self._isatty(procutil.stderr): |
1546 os.dup2(pager.stdin.fileno(), procutil.stderr.fileno()) | 1546 os.dup2(pager.stdin.fileno(), procutil.stderr.fileno()) |
1547 | 1547 |
1548 @self.atexit | 1548 @self.atexit |
1549 def killpager(): | 1549 def killpager(): |
1550 if util.safehasattr(signal, "SIGINT"): | 1550 if hasattr(signal, "SIGINT"): |
1551 signal.signal(signal.SIGINT, signal.SIG_IGN) | 1551 signal.signal(signal.SIGINT, signal.SIG_IGN) |
1552 # restore original fds, closing pager.stdin copies in the process | 1552 # restore original fds, closing pager.stdin copies in the process |
1553 os.dup2(stdoutfd, procutil.stdout.fileno()) | 1553 os.dup2(stdoutfd, procutil.stdout.fileno()) |
1554 os.dup2(stderrfd, procutil.stderr.fileno()) | 1554 os.dup2(stderrfd, procutil.stderr.fileno()) |
1555 pager.stdin.close() | 1555 pager.stdin.close() |