Looks like py3 raises AttributeError instead of ImportError. This is caught on
windows.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
Looks like py3 raises AttributeError instead of ImportError. This is caught on
windows.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/color.py (2 lines) | |||
M | mercurial/crecord.py (4 lines) | |||
M | tests/hghave.py (2 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
94f6ff5989ae | 806d14efec8d | Pulkit Goyal | Jan 21 2020, 4:47 PM |
b'red': (False, curses.COLOR_RED, b''), | b'red': (False, curses.COLOR_RED, b''), | ||||
b'green': (False, curses.COLOR_GREEN, b''), | b'green': (False, curses.COLOR_GREEN, b''), | ||||
b'yellow': (False, curses.COLOR_YELLOW, b''), | b'yellow': (False, curses.COLOR_YELLOW, b''), | ||||
b'blue': (False, curses.COLOR_BLUE, b''), | b'blue': (False, curses.COLOR_BLUE, b''), | ||||
b'magenta': (False, curses.COLOR_MAGENTA, b''), | b'magenta': (False, curses.COLOR_MAGENTA, b''), | ||||
b'cyan': (False, curses.COLOR_CYAN, b''), | b'cyan': (False, curses.COLOR_CYAN, b''), | ||||
b'white': (False, curses.COLOR_WHITE, b''), | b'white': (False, curses.COLOR_WHITE, b''), | ||||
} | } | ||||
except ImportError: | except (ImportError, AttributeError): | ||||
curses = None | curses = None | ||||
_baseterminfoparams = {} | _baseterminfoparams = {} | ||||
# start and stop parameters for effects | # start and stop parameters for effects | ||||
_effects = { | _effects = { | ||||
b'none': 0, | b'none': 0, | ||||
b'black': 30, | b'black': 30, | ||||
b'red': 31, | b'red': 31, |
""" | """ | ||||
) | ) | ||||
try: | try: | ||||
import curses | import curses | ||||
import curses.ascii | import curses.ascii | ||||
curses.error | curses.error | ||||
except ImportError: | except (ImportError, AttributeError): | ||||
# I have no idea if wcurses works with crecord... | # I have no idea if wcurses works with crecord... | ||||
try: | try: | ||||
import wcurses as curses | import wcurses as curses | ||||
curses.error | curses.error | ||||
except ImportError: | except (ImportError, AttributeError): | ||||
# wcurses is not shipped on Windows by default, or python is not | # wcurses is not shipped on Windows by default, or python is not | ||||
# compiled with curses | # compiled with curses | ||||
curses = False | curses = False | ||||
class fallbackerror(error.Abort): | class fallbackerror(error.Abort): | ||||
"""Error that indicates the client should try to fallback to text mode.""" | """Error that indicates the client should try to fallback to text mode.""" | ||||
@check("tic", "terminfo compiler and curses module") | @check("tic", "terminfo compiler and curses module") | ||||
def has_tic(): | def has_tic(): | ||||
try: | try: | ||||
import curses | import curses | ||||
curses.COLOR_BLUE | curses.COLOR_BLUE | ||||
return matchoutput('test -x "`which tic`"', br'') | return matchoutput('test -x "`which tic`"', br'') | ||||
except ImportError: | except (ImportError, AttributeError): | ||||
return False | return False | ||||
@check("xz", "xz compression utility") | @check("xz", "xz compression utility") | ||||
def has_xz(): | def has_xz(): | ||||
# When Windows invokes a subprocess in shell mode, it uses `cmd.exe`, which | # When Windows invokes a subprocess in shell mode, it uses `cmd.exe`, which | ||||
# only knows `where`, not `which`. So invoke MSYS shell explicitly. | # only knows `where`, not `which`. So invoke MSYS shell explicitly. | ||||
return matchoutput("sh -c 'test -x \"`which xz`\"'", b'') | return matchoutput("sh -c 'test -x \"`which xz`\"'", b'') |