Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

try/except/else clauses can't be typed, code input stops too early. #290

Closed
fperez opened this Issue Mar 13, 2011 · 4 comments

Comments

Projects
None yet
2 participants
Owner

fperez commented Mar 13, 2011

Trying to input code like:

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

is currently impossible in master, regardless of autoindent state:

In [1]: try:
   ...:     a=5
   ...: except:
   ...:     raise

In [2]: autoindent
Automatic indentation is: OFF

In [3]: try:
   ...:     a=5
   ...: except:
   ...:     raise

In [4]: 

what happens is that immediately after the raise statement is entered, the input handling code thinks we're done, and it stops accepting more input.

The problem occurs both in the terminal and in the qtconsole, because the bug itself is most likely in inputsplitter, which is being to aggressive to bail out early when encountering a 'raise' statement.

Owner

fperez commented Mar 13, 2011

I should add that this works fine on 0.10.2, it's only in the 0.11 series that uses inputsplitter that we have a problem.

Owner

takluyver commented Mar 22, 2011

More specifically, input_splitter.push_accepts_more returns False if we have no indent, and it's automatically dedented after "raise", "pass" or "return". I think we could change the conditions so that, if more than one line has been entered, a blank final line is always necessary. This is like what is already done for 'cell' mode, but that checks if more than 1 block has been entered: I'm suggesting checking if more than one line has been entered.

Owner

takluyver commented Mar 23, 2011

OK, I did this in a slightly more sophisticated way. See pull request #294.

Owner

takluyver commented Mar 25, 2011

Require blank line to end input cell immediately after dedenting.

Closed by 950a970

@takluyver takluyver closed this Mar 25, 2011

@markvoorhies markvoorhies pushed a commit to markvoorhies/ipython that referenced this issue Apr 21, 2011

@takluyver takluyver Require blank line to end input cell immediately after dedenting.
Closes gh-290
950a970

@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

@takluyver takluyver Require blank line to end input cell immediately after dedenting.
Closes gh-290
1049e72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment