Skip to content
This repository

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

Closed
wants to merge 1 commit into from

3 participants

Thomas Kluyver Fernando Perez Min RK
Thomas Kluyver
Collaborator

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

Closes gh-1100

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

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

Thomas Kluyver Collaborator

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
Fernando Perez
Owner

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

Fernando Perez
Owner

Pushed after rebase, closing.

Fernando Perez fperez closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 05, 2011
Thomas Kluyver Fix display of errors in compiled code on Python 3.
Closes gh-1100
3357017
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  IPython/core/ultratb.py
2  IPython/core/ultratb.py
@@ -879,7 +879,7 @@ def linereader(file=file, lnum=[lnum], getline=linecache.getline):
879 879
                 # enclosing scope.
880 880
                 for token in generate_tokens(linereader):
881 881
                     tokeneater(*token)
882  
-            except IndexError:
  882
+            except (IndexError, UnicodeDecodeError):
883 883
                 # signals exit of tokenizer
884 884
                 pass
885 885
             except tokenize.TokenError,msg:
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.