Closed tchakravarty closed 9 years ago
Hi @tchakravarty,
I haven't seen this issue before. I use IPython quite a lot myself and haven't seen this. Are you using an IPython shell (i.e., ipython -i
) or IPython Notebook? My suggestion would be to put a break point (import ipdb; ipdb.set_trace()
) before the line output = repr(obj)
and inspect the obj
variable. That appears to be the wrong type, so perhaps inspecting it a bit could provide some clues.
Let me know if you find anything.
Thanks, Rodney
Hi @rodneykeeling, I am using the IPython console from within PyCharm. But please note that Martijn Pieters is claiming that this is a bug over on SO, and he is not often wrong... :-)
Ah, I see. I am still primarily using Python 2.7.9.
I added those .encode('utf-8')
bits in there because some characters in Python 2 were having encoding issues. I'll see if I can find a nice middleground to get both Python 2 & 3 working.
Thanks, Rodney
Not very elegant, but something like this should work:
r = ... # create something with unicode
if sys.version_info[0] < 3:
return r.encode('utf-8')
return r
UTF-8 will not always be the right encoding, especially on Windows, but if it's mostly ascii characters you can get away with it.
@takluyver Yeah, creating a method that does that in one of the parent classes seems like the least intrusive option since there are so many __repr__()
methods.
Got a PR up here #56. Would love it if someone could test it. I tried it using Python 2.7.9 and 3.4.0 and it seems to work fine.
Here is a minimal example of my attempts to interact with the Discogs API:
The functions
provide_discogs_auth
andprovide_verifier
simply return the consumer key & secret and the verifier from user authorization.get_access_token
returns the access key and secret as expected.However, on the last line, when I make an API call, I get:
Not sure if this is related to IPython or the client library, but would appreciate help either way. Thanks.