py3: catch AttributeError too with ImportError
authorPulkit Goyal <7895pulkit@gmail.com>
Wed, 22 Jan 2020 03:17:06 +0530
changeset 44264 d3f776c4760e
parent 44263 beea86e4d332
child 44265 c18dd48cea4a
py3: catch AttributeError too with ImportError Looks like py3 raises AttributeError instead of ImportError. This is caught on windows. Differential Revision: https://phab.mercurial-scm.org/D7965
mercurial/color.py
mercurial/crecord.py
tests/hghave.py
--- a/mercurial/color.py	Wed Feb 05 15:15:18 2020 -0500
+++ b/mercurial/color.py	Wed Jan 22 03:17:06 2020 +0530
@@ -44,7 +44,7 @@
         b'cyan': (False, curses.COLOR_CYAN, b''),
         b'white': (False, curses.COLOR_WHITE, b''),
     }
-except ImportError:
+except (ImportError, AttributeError):
     curses = None
     _baseterminfoparams = {}
 
--- a/mercurial/crecord.py	Wed Feb 05 15:15:18 2020 -0500
+++ b/mercurial/crecord.py	Wed Jan 22 03:17:06 2020 +0530
@@ -63,13 +63,13 @@
     import curses.ascii
 
     curses.error
-except ImportError:
+except (ImportError, AttributeError):
     # I have no idea if wcurses works with crecord...
     try:
         import wcurses as curses
 
         curses.error
-    except ImportError:
+    except (ImportError, AttributeError):
         # wcurses is not shipped on Windows by default, or python is not
         # compiled with curses
         curses = False
--- a/tests/hghave.py	Wed Feb 05 15:15:18 2020 -0500
+++ b/tests/hghave.py	Wed Jan 22 03:17:06 2020 +0530
@@ -685,7 +685,7 @@
 
         curses.COLOR_BLUE
         return matchoutput('test -x "`which tic`"', br'')
-    except ImportError:
+    except (ImportError, AttributeError):
         return False