ipython/ipython — Issue #1177: UnicodeDecodeError in py3compat from "xlrd??"
Author: jdmarch
Created: 2011-12-18 22:27:37+00:00
State: open

EPD python 2.7 and xlrd
ipython from master

Windows or OSX. Here is traceback on OSX:

```
In [1]: import xlrd

In [2]: xlrd??
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (11, 0))
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
/Users/jmarch/ in ()
----> 1 get_ipython().magic(u'pinfo2 xlrd')

/Users/jmarch/ipython/IPython/core/interactiveshell.pyc in magic(self, arg_s, next_input)
1996 self._magic_locals = sys._getframe(1).f_locals
1997 with self.builtin_trap:
-> 1998 result = fn(magic_args)
1999 # Ensure we're not keeping object references around:

2000 self._magic_locals = {}

/Users/jmarch/ipython/IPython/core/magic.py in magic_pinfo2(self, parameter_s, namespaces)
564 '%pinfo2 object' is just a synonym for object?? or ??object."""
565 self.shell._inspect('pinfo', parameter_s, detail_level=1,
--> 566 namespaces=namespaces)
567
568 @skip_doctest

/Users/jmarch/ipython/IPython/core/interactiveshell.pyc in _inspect(self, meth, oname, namespaces, **kw)
1416 pmethod(info.obj, oname, formatter)
1417 elif meth == 'pinfo':
-> 1418 pmethod(info.obj, oname, formatter, info, **kw)
1419 else:
1420 pmethod(info.obj, oname)

/Users/jmarch/ipython/IPython/core/oinspect.pyc in pinfo(self, obj, oname, formatter, info, detail_level)
458 # source found.

459 if detail_level > 0 and info['source'] is not None:
--> 460 displayfields.append(("Source", self.format(py3compat.unicode_to_str(info['source']))))
461 elif info['docstring'] is not None:
462 displayfields.append(("Docstring", info["docstring"]))

/Users/jmarch/ipython/IPython/utils/py3compat.pyc in encode(u, encoding)
18 def encode(u, encoding=None):
19 encoding = encoding or sys.stdin.encoding or sys.getdefaultencoding()
---> 20 return u.encode(encoding, "replace")
21
22 def cast_unicode(s, encoding=None):

UnicodeDecodeError: 'ascii' codec can't decode byte 0xa9 in position 77: ordinal not in range(128)
```