Message121117
| Author |
loewis |
| Recipients |
benjamin.peterson, bobbyi, eric.araujo, hfuru, loewis, vstinner |
| Date |
2010年11月13日.06:53:11 |
| SpamBayes Score |
3.335684e-07 |
| Marked as misclassified |
No |
| Message-id |
<4CDE35D6.6020103@v.loewis.de> |
| In-reply-to |
<1289611734.06.0.674944392154.issue10070@psf.upfronthosting.co.za> |
| Content |
> 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. |
|