IPython - Enhanced Interactive Python

syntax error when raise is inside except process

Reported by Jianping Hua on 2010-02-21
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IPython
Triaged
Undecided
Unassigned

Bug Description

Python 2.6.2, ipython 0.10, Mac OSX leopard.

I need to re-raise some exception in the exception processing, but when I copy & paste the copy from my editor for following test code, I encounter the syntax error.

The code:
try:
    a = 5
except:
    raise
else:
    print a

The ipython error:
In [565]: try:
   .....: a = 5
   .....: except:
   .....: raise
   .....: else:
------------------------------------------------------------
   File "<ipython console>", line 5
     lse:
       ^
SyntaxError: invalid syntax

If I manually input the above code, there is no problem:
In [568]: try:
   .....: a = 5
   .....: except:
   .....: raise
   .....: else:
   .....: print a
   .....:
   .....:
5

But even with manual input, if I add 4 additional space at each indention (actually only the one before 'raise' matters), I got the same error

Jianping Hua (talich) wrote :

This looks like a problem with autoindent feature in ipython.

Anyway, now I disabled the autoindent to avoid it.

Fernando Perez (fdo.perez) wrote :

Correct, I can reproduce the bug though, so we should be able to track it down. Thanks for reporting it.

Changed in ipython:
status: New → Confirmed
status: Confirmed → Triaged
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers