py3: also catch ImportError when relative import fails
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 17 Jul 2019 12:47:20 -0700
changeset 4760 7e034d44bd4b
parent 4759 f30c1fab7155
child 4761 2c3fd1bb2752
py3: also catch ImportError when relative import fails Python 3 apparently raises an ImportError where Python 2 raised a ValueError.
hgext3rd/evolve/serveronly.py
--- 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__)))