[MERGE] Good python practice: specify which exception to catch.

Adeodato Simó dato at net.com.org.es
Fri Dec 28 10:55:13 UTC 2007


* Enrico Zini [Fri, 28 Dec 2007 10:26:21 +0800]:

> On Thu, Dec 27, 2007 at 06:09:03PM +0100, Adeodato Simó wrote:

> >  try:
> >      maint_RE = re.compile(sys.argv[1])
> > -except:
> > +except IndexError:
> >      print "Usage: grep-maintainer REGEXP"
> >      sys.exit(1)

> +1.

Thanks for the review! (And the other one too, I've merged it.)

> You may however want to also catch "sre_constants.error" (what a
> stupid exception name is that?) to show nice error messages in case of
> malformed regexps.  Oh, and print errors to sys.stderr:

Oh, yay peer review. I've changed those two things, but catched
"re.error" instead. ;-)

Cheers,

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
You cannot achieve the impossible without attempting the absurd.




More information about the pkg-python-debian-discuss mailing list