Patchwork D7965: py3: catch AttributeError too with ImportError

login
register
mail settings
Submitter phabricator
Date Feb. 6, 2020, 4:11 p.m.
Message ID <57d2525e69a54cc92ca5cbe250ce57b0@localhost.localdomain>
Download mbox | patch
Permalink /patch/44994/
State Not Applicable
Headers show

Comments

phabricator - Feb. 6, 2020, 4:11 p.m.
Closed by commit rHG9a92b29cf930: py3: catch AttributeError too with ImportError (authored by pulkit).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7965?vs=19499&id=19953

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7965/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7965

AFFECTED FILES
  mercurial/color.py
  mercurial/crecord.py
  tests/hghave.py

CHANGE DETAILS




To: pulkit, #hg-reviewers, marmoute
Cc: marmoute, mercurial-devel

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -685,7 +685,7 @@ 
 
         curses.COLOR_BLUE
         return matchoutput('test -x "`which tic`"', br'')
-    except ImportError:
+    except (ImportError, AttributeError):
         return False
 
 
diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -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
diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -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 = {}