Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ipython3 traceback unicode issue from extensions #1100

Closed
juliantaylor opened this Issue · 1 comment

2 participants

@juliantaylor
Collaborator

ipython3 has issues when displaying context of an exception originating from an pythone extension. it works without context (plain xmode)
e.g. with pyzmq:

%xmode context
import zmq
ctx = zmq.Context()
so = ctx.socket(zmq.REQ)
#intentional error, expected AttributeError: Socket has no such option: SENT
so.sent("test")

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py in run_code(self, code_obj)
   2545             self.CustomTB(etype,value,tb)
   2546         except:
-> 2547             self.showtraceback()
   2548         else:
   2549             outflag = 0

/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py in showtraceback(self, exc_tuple, filename, tb_offset, exception_only)
   1636                     else:
   1637                         stb = self.InteractiveTB.structured_traceback(etype,
-> 1638                                                 value, tb, tb_offset=tb_offset)
   1639 
   1640                         self._showtraceback(etype, value, stb)

/usr/lib/python3/dist-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, context)
   1174         self.tb = tb
   1175         return FormattedTB.structured_traceback(
-> 1176             self, etype, value, tb, tb_offset, context)
   1177 
   1178 #---------------------------------------------------------------------------


/usr/lib/python3/dist-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, context)
   1082             # Verbose modes need a full traceback

   1083             return VerboseTB.structured_traceback(
-> 1084                 self, etype, value, tb, tb_offset, context
   1085             )
   1086         else:

/usr/lib/python3/dist-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, context)
    878                 # This builds the names list in-place by capturing it from the

    879                 # enclosing scope.

--> 880                 for token in generate_tokens(linereader):
    881                     tokeneater(*token)
    882             except IndexError:

/usr/lib/python3.2/tokenize.py in _tokenize(readline, encoding)
    391     while True:             # loop over lines in stream
    392         try:
--> 393             line = readline()
    394         except StopIteration:
    395             line = b''

/usr/lib/python3/dist-packages/IPython/core/ultratb.py in linereader(file, lnum, getline)
    869 
    870             def linereader(file=file, lnum=[lnum], getline=linecache.getline):
--> 871                 line = getline(file, lnum[0])
    872                 lnum[0] += 1
    873                 return line

/usr/lib/python3.2/linecache.py in getline(filename, lineno, module_globals)
     13 
     14 def getline(filename, lineno, module_globals=None):
---> 15     lines = getlines(filename, module_globals)
     16     if 1 <= lineno <= len(lines):
     17         return lines[lineno-1]

/usr/lib/python3.2/linecache.py in getlines(filename, module_globals)
     39         return cache[filename][2]
     40     else:
---> 41         return updatecache(filename, module_globals)
     42 
     43 

/usr/lib/python3.2/linecache.py in updatecache(filename, module_globals)
    130     try:
    131         with tokenize.open(fullname) as fp:
--> 132             lines = fp.readlines()
    133     except IOError:
    134         return []

/usr/lib/python3.2/codecs.py in decode(self, input, final)
    298         # decode input (taking the buffer into account)

    299         data = self.buffer + input
--> 300         (result, consumed) = self._buffer_decode(data, self.errors, final)
    301         # keep undecoded input until the next call

    302         self.buffer = data[consumed:]

UnicodeDecodeError: 'utf8' codec can't decode byte 0xc0 in position 96: invalid start byte
@takluyver takluyver was assigned
@takluyver
Owner

I've assigned this to myself to have a look at. I have a feeling I found and fixed the issue in the pure-Python 3 port I did for 0.11, so hopefully it will be an easy fix here.

@takluyver takluyver referenced this issue from a commit in takluyver/ipython
@takluyver takluyver Fix display of errors in compiled code on Python 3.
Closes gh-1100
3357017
@takluyver takluyver closed this in 411ba6a
@fperez fperez referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@takluyver takluyver Fix display of errors in compiled code on Python 3.
Closes gh-1100
9f965f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.