From: robin Date: Sat, 27 Jan 2018 18:02:30 +0000 (-0500) Subject: Raise the sqlite3 import error, not the pysqlite2 one X-Git-Tag: rel_1_2_3~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fac520b2a1d168387319548c6674d89928f0067;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Raise the sqlite3 import error, not the pysqlite2 one Fixed the import error raised when a platform has neither pysqlite2 nor sqlite3 installed, such that the sqlite3-related import error is raised, not the pysqlite2 one which is not the actual failure mode. Pull request courtesy Robin. Origin version only print `No module named pysqlite2` even it's actually the import error of line 337: `from sqlite3 import dbapi2 as sqlite` which point user to the wrong debug direction. It should raise `e.message` as `No module named _sqlite3`. Change-Id: Idc39cd0d226957fd670859df23a2386dea6eb3cc Pull-request: https://github.com/zzzeek/sqlalchemy/pull/417 --- diff --git a/doc/build/changelog/unreleased_12/sqlite_import.rst b/doc/build/changelog/unreleased_12/sqlite_import.rst new file mode 100644 index 0000000000..55f3eb5117 --- /dev/null +++ b/doc/build/changelog/unreleased_12/sqlite_import.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, sqlite + + Fixed the import error raised when a platform + has neither pysqlite2 nor sqlite3 installed, such + that the sqlite3-related import error is raised, + not the pysqlite2 one which is not the actual + failure mode. Pull request courtesy Robin. diff --git a/lib/sqlalchemy/dialects/sqlite/pysqlite.py b/lib/sqlalchemy/dialects/sqlite/pysqlite.py index a5e84f7bcd..8809962df2 100644 --- a/lib/sqlalchemy/dialects/sqlite/pysqlite.py +++ b/lib/sqlalchemy/dialects/sqlite/pysqlite.py @@ -332,10 +332,10 @@ class SQLiteDialect_pysqlite(SQLiteDialect): def dbapi(cls): try: from pysqlite2 import dbapi2 as sqlite - except ImportError as e: + except ImportError: try: from sqlite3 import dbapi2 as sqlite # try 2.5+ stdlib name. - except ImportError: + except ImportError as e: raise e return sqlite