[Python-Dev] pre.sub's broken under 2.2
Tim Peters
tim@zope.com
Thu, 27 Jun 2002 15:30:00 -0400
[/F]
> just for the record, one of those "let's change a lot of
> code that we don't understand, just because we can"
In the case of try + bare-except, it was more a case of "let's change code
we don't understand because it's impossible to guess its intent and that's
bad for future maintenance".
> things broke the "pre" module in 2.2.
>
> someone changed:
>
> try:
> repl = pcre_expand(_Dummy, repl)
> except:
> m = MatchObject(self, source, 0, end, [])
>
> to
>
> try:
> repl = pcre_expand(_Dummy, repl)
> except error:
> m = MatchObject(self, source, 0, end, [])
>
> but in the most common use case (replacement strings
> containing group references), the pcre_expand function
> raises a TypeError exception...
Like I said <wink>. The except clause should list the exceptions it
specifically intends to silence, and something as obscure as this case
deserves a comment to boot.
I also note that if this passed the tests, then the test suite wasn't even
trying "the most common use case".
there's-more-than-one-kind-of-breakage-illustrated-here-ly y'rs - tim