Out-of-tree dialects won't import in IPython / rpdb2

Issue #1630 resolved
Former user created an issue

Out-of-tree dialects found with pkg_resources can't be used in IPython because sys.exc_info()[2](2).tb_next is not None. I think that's because, under (my) IPython, SQLAlchemy is under the influence of the rpdb2 import hook.

e.g. {{{ ipython -c "import sqlalchemy; sqlalchemy.create_engine('fictional://dialect')" }}} won't work even if there is a sqlalchemy.dialects entry point named fictional.

I made this change to compensate:

Index: lib/sqlalchemy/engine/url.py
===================================================================
--- lib/sqlalchemy/engine/url.py        (revision 6511)
+++ lib/sqlalchemy/engine/url.py        (working copy)
@@ -101,13 +101,14 @@
             module = getattr(module, driver)

             return module.dialect
-        except ImportError:
-            if sys.exc_info()[2](2).tb_next is None:
+        except ImportError, e:
+            try:
                 import pkg_resources
                 for res in pkg_resources.iter_entry_points('sqlalchemy.dialects'):
                     if res.name == self.drivername:
                         return res.load()
-            raise
+            except ImportError, j:
+                raise e

Comments (5)

  1. Former user Account Deleted

    I think the author was trying to detect

    import exists
    
    exists.py:
    import does_not_exist
    
  2. Log in to comment