raise not inside exception block

Bug #1528539 reported by John Vandenberg
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pyflakes
Won't Fix
Undecided
Unassigned

Bug Description

`raise` without any arguments inside an exception block can re-raise the exception.

outside an exception block it causes the following on at least 2.7:

TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType

Revision history for this message
John Vandenberg (jayvdb) wrote :
Revision history for this message
Phil Frost (bitglue) wrote :

This is valid Python code:

def foo():
    raise

def bar():
    try:
        raise Exception()
    except:
        foo()

As such, a `raise` outside an `except:` block isn't an error per se: it depends on the call stack from which its called. Since we can't know that until runtime I don't think it's something Pyflakes can check.

Changed in pyflakes:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.