# HG changeset patch # User Sean Farley # Date 2015-12-16 18:33:19 # Node ID 7cc654610204bc495d8082e8d52180e87b0097ae # Parent 707cdf2c370093601865bc4a489fbc3e1b167aa0 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). diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -30,15 +30,18 @@ from . import ( # 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