This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: uncaught TypeError exception in sre
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: effbot Nosy List: effbot, nnorwitz
Priority: normal Keywords: patch

Created on 2002-07-12 02:11 by nnorwitz, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sre.diff nnorwitz, 2002-07-12 02:11 sre.py patch to catch TypeError
Messages (3)
msg40558 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-07-12 02:11
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().
msg40559 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-07-12 03:05
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
msg40560 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2002-07-12 11:07
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
History
Date User Action Args
2022-04-10 16:05:30adminsetgithub: 36879
2002-07-12 02:11:20nnorwitzcreate