Mercurial > hg-stable
changeset 27528:7cc654610204 stable
crecord: use try/except for import of curses
Not only does this improve fragility with 'if os.name == ...' it will help
future patches enable the behavior to fallback to use plain record when curses
is unavailable (e.g. python compiled without curses support).
author | Sean Farley <sean@farley.io> |
---|---|
date | Wed, 16 Dec 2015 10:33:19 -0800 |
parents | 707cdf2c3700 |
children | 940cedaee988 |
files | mercurial/crecord.py |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/crecord.py Wed Dec 23 22:28:52 2015 +0900 +++ b/mercurial/crecord.py Wed Dec 16 10:33:19 2015 -0800 @@ -30,15 +30,18 @@ # locale encoding correctly. --immerrr locale.setlocale(locale.LC_ALL, '') -# os.name is one of: 'posix', 'nt', 'dos', 'os2', 'mac', or 'ce' -if os.name == 'posix': +try: import curses import fcntl import termios -else: + curses.error + fcntl.ioctl + termios.TIOCGWINSZ +except ImportError: # I have no idea if wcurses works with crecord... try: import wcurses as curses + curses.error except ImportError: # wcurses is not shipped on Windows by default pass