Martin v. Löwis <[email protected]> added the comment:
> Consider here:
> http://www.sqlalchemy.org/trac/browser/lib/sqlalchemy/engine/base.py?rev=6884:b181f1e53603#L1329
> the py3k code uses the "raise ... from" syntax which isn't legal in Python 2.
In this case, I would write
error = exc.DBAPIError.instance(statement,
parameters,
e,
connection_invalidated=is_disconnect)
if sys.version_info < (3,):
raise error, None, sys.exc_info()[2]
else:
error.__cause__ = e
raise error
You don't *have* to use the from syntax to set the cause.
> Approach B isn't a general solution because it requires you to replace entire
> functions at a time.
I don't claim that. However, I claim that there will be always an
appropriate solution using existing techniques, so that such a macro
processing wouldn't be necessary. IOW, I'm not aware of a case where
using such preprocessing would be appropriate and better than what
you can do without.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue10070>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com