[ python-Bugs-973103 ] empty raise after handled exception

SourceForge.net noreply at sourceforge.net
Thu Jun 24 06:06:30 EDT 2004


Bugs item #973103, was opened at 2004-06-15 09:36
Message generated for change (Comment added) made by arigo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=973103&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Niki Spahiev (nikis)
Assigned to: Nobody/Anonymous (nobody)
Summary: empty raise after handled exception

Initial Comment:
executing empty raise after handled exception produces
wrong traceback.

no exception:

Traceback (most recent call last):
  File "bug.py", line 19, in ?
    test(i)
  File "bug.py", line 15, in test
    badfn()
  File "bug.py", line 5, in badfn
    raise
TypeError: exceptions must be classes, instances, or
strings (deprecated), not NoneType

handled exception:

no
Traceback (most recent call last):
  File "bug.py", line 19, in ?
    test(i)
  File "bug.py", line 15, in test
    badfn()
  File "bug.py", line 11, in test
    print d[12345]
KeyError: 12345


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

>Comment By: Armin Rigo (arigo)
Date: 2004-06-24 10:06

Message:
Logged In: YES 
user_id=4771

This is the intended behavior, although the docs that explain that are not too clear: "raise" is equivalent to re-raising what "sys.get_info()" returns; the docs about sys.get_info() explain in detail why you get this behavior.

The language reference 6.9 should mention this.  (Btw the language reference 7.4 still says that continue is illegal within try:finally:, which is no longer the case.)

The reason sys.get_info() has access to the exception handled in a parent frame is to be able to implement things like traceback.print_exc().  But I don't know exactly why it should be the case that an exception remains active after its handler finished.

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

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



More information about the Python-bugs-list mailing list