On 21 June 2011 10:23, Wichert Akkerman <wich...@wiggy.net> wrote: > > On 06/21/2011 11:21 AM, Lennart Regebro wrote: >> >> On Tue, Jun 21, 2011 at 10:34, Vinay Sajip<vinay_sa...@yahoo.co.uk> wrote: >>> >>> I'm testing a branch of Python which provides out-of-the-box ability to >>> create >>> virtual enviroments à la virtualenv, and as part of that testing I have to >>> install Distribute in newly created environments a lot. Though normally >>> running >>> 2to3 as part of the Distribute installation is not a big deal, for this >>> testing >>> I'm doing, it does slow things down a little. >>> >>> While waiting for some tests to finish, I thought I might as well look into >>> whether Distribute could be made to run on 2.x and 3.x from a single code >>> base, >>> thereby avoiding the 2to3 step. >>> >>> I've made an attempt, and things seem to have gone reasonably smoothly: the >>> conversion is done and all unit tests pass on 2.7, 3.2, 3.3 (my branch). >> >> We still need to support Python 2.4, right? That's a trickier issue. >> But including six.py might help. > > Afaik you can't catch exceptions in a way that is source-compatible with > python 3.x and <2.6 due to the switch from "except <class>, <variable> to > "except <class> as <variable>".
You can, it just isn't particularly pretty - virtualenv and pip access the variable via sys.exc_info()[1], eg: except Exception: e = sys.exc_info()[1] Paul _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig