changeset 4760:7e034d44bd4b

py3: also catch ImportError when relative import fails Python 3 apparently raises an ImportError where Python 2 raised a ValueError.
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 17 Jul 2019 12:47:20 -0700
parents f30c1fab7155
children 2c3fd1bb2752
files hgext3rd/evolve/serveronly.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/serveronly.py	Fri Jul 12 10:26:41 2019 -0700
+++ b/hgext3rd/evolve/serveronly.py	Wed Jul 17 12:47:20 2019 -0700
@@ -23,8 +23,9 @@
         obscache,
         obsexchange,
     )
-except ValueError as exc:
-    if str(exc) != 'Attempted relative import in non-package':
+except (ValueError, ImportError) as exc:
+    if (isinstance(exc, ValueError)
+        and str(exc) != 'Attempted relative import in non-package'):
         raise
     # extension imported using direct path
     sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))