[Patches] [ python-Patches-580386 ] uncaught TypeError exception in sre

noreply@sourceforge.net noreply@sourceforge.net
Fri, 12 Jul 2002 04:07:58 -0700


Patches item #580386, was opened at 2002-07-12 04:11
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=580386&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
>Resolution: Duplicate
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Fredrik Lundh (effbot)
Summary: uncaught TypeError exception in sre

Initial Comment:
>From c.l.p on 9 July, Kevin Altis reported that:

    re.compile('([a-')

Produces an uncaught TypeError from compilation.

This patch catches the TypeError in _compile().

----------------------------------------------------------------------

>Comment By: Fredrik Lundh (effbot)
Date: 2002-07-12 13:07

Message:
Logged In: YES 
user_id=38376

this is same as bug #545855, and should be fixed inside
the SRE parser (afaik, it has been, in the SLAB master
repository).

as for the extra try/except: this is to shield ordinary users
from 20-level tracebacks exposing irrelevant implementation
details .  if you make a mistake in an RE, you want to know
that, but you probably don't care about exactly where in the
parser or compiler internals the interpreter happens to be
when that mistake was discovered...  (this pattern, along
with the "add a comment on the raise line, to provide extra
hints for a human reader" idiom, are pretty common in
Python libraries). /F

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-07-12 05:05

Message:
Logged In: YES 
user_id=33168

I wonder if the same change must be made in _compile_repl().

I don't see the benefit of the try/except clause as it is:

  try:
    p = parse...
  except error, v:
    raise error, v
Isn't that just:  p = parse...

This probably also should be backported to 2.2

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=580386&group_id=5470