[Python-Dev] Re: PEP-317
Raymond Hettinger
python@rcn.com
Mon, 9 Jun 2003 13:47:43 -0400
> Quoth Terry Reedy:
> [...]
> > A conversion utility that converted 'raise item' to 'raise item()' and
> > 'raise item,arg' to 'raise item(arg)' would definitely be helpful. A
> > working version, or at least a promise to produce one on acceptance
> > might make the PEP more palatable.
>
> I do intend to write such a tool.
>
> I'd imagined that, being PEP champion, I would be the obvious
> person to produce the relevant patches to the standard library.
> There are more than a thousand raise statements there, mostly of
> the implicitly instantiating type, so you can bet I'm not doing it
> by hand if I can avoid it.
PEP-290 advises against automated tools for this type of change.
Every line of code needs to be read and understood before
changing it. Then, each change should be reviewed. It's the only
way to make sure you're not introducing mindless cut and paste
errors throughout the code. It is for this reason that I've spent
more than one weekend reviewing every line of Walter's code
updates -- he does them by hand and has less than a 2% error rate.
Also, take a look at what would need to be done to the test suite.
The changes there are less amenable to an automated update.
Grep could find most potential changes but I don't see how
you can statically determine whether 'raise x'
is a class or instance without running the code.
That brings up the question of whether the warnings are a
runtime or compile time event. Can you always determine
at compile time whether raise Class is being used? If not,
the performance penalty for the warnings module is something
else to consider.
Except for conceptual purity, is there any real payoff in terms
of performance or capability that would warrant a wholesale
revision of working code?
Raymond Hettinger
#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################