Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix display of errors in compiled code on Python 3 #1106

Closed
wants to merge 1 commit into from

3 participants

@takluyver
Owner

@juliantaylor, I've checked this, and it appears to solve the issue in Python 3.

Closes gh-1100

@minrk minrk commented on the diff
IPython/core/ultratb.py
@@ -879,7 +879,7 @@ def linereader(file=file, lnum=[lnum], getline=linecache.getline):
# enclosing scope.
for token in generate_tokens(linereader):
tokeneater(*token)
- except IndexError:
+ except (IndexError, UnicodeDecodeError):
@minrk Owner
minrk added a note

Is there any reason this should casta wider net? If not, go ahead and merge.

@takluyver Owner

As far as I know, only these errors can be raised, but it's a part of the machinery I'm not familiar with.

My rationale would be: any other exceptions arising here are likely unusual corner cases, so they shouldn't have a big impact on day-to-day use. On the other hand, they might highlight something we're doing wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fperez
Owner

Looks good, merging now with rebase to avoid recursive merge on just one commit.

@fperez
Owner

Pushed after rebase, closing.

@fperez fperez closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 5, 2011
  1. @takluyver
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  IPython/core/ultratb.py
View
2  IPython/core/ultratb.py
@@ -879,7 +879,7 @@ def linereader(file=file, lnum=[lnum], getline=linecache.getline):
# enclosing scope.
for token in generate_tokens(linereader):
tokeneater(*token)
- except IndexError:
+ except (IndexError, UnicodeDecodeError):
@minrk Owner
minrk added a note

Is there any reason this should casta wider net? If not, go ahead and merge.

@takluyver Owner

As far as I know, only these errors can be raised, but it's a part of the machinery I'm not familiar with.

My rationale would be: any other exceptions arising here are likely unusual corner cases, so they shouldn't have a big impact on day-to-day use. On the other hand, they might highlight something we're doing wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
# signals exit of tokenizer
pass
except tokenize.TokenError,msg:
Something went wrong with that request. Please try again.