New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#769 (reopened) #770
#769 (reopened) #770
Conversation
@takluyver, does this seem more reasonable for the json_clean? It now performs the same check as elsewhere, which still fails to get an answer in plenty of situations, and cleans more than just oinfo messages. |
@takluyver perhaps we should have an |
It seems like |
updated with |
confirming that issue described in #775 is fixed by this PL |
Confirmed as closing #768 |
This is a central location for the many places we call sys.stdin.encoding or sys.getdefaultencoding(), which now adds locale.getpreferredencoding(False) after stdin.encoding, which should be a better guess when stdin.encoding is None.
Just a note, Min: this one doesn't seem to solve the weird errors on %debug in the console I was mentioning today. To reproduce those:
At 3, I see little triangle junk characters in the traceback printout. If the traceback was generated from |
@fperez, too bad it's not this. Can you get info on the characters that are being printed? I should note that I can't actually reproduce what you describe by following your instructions (with a 1/0 error). |
Weird, here's a screenshot of what I get: http://imgur.com/RWa10 I've tried it with a few different fonts in the Qt widget and I get the same thing, so it doesn't seem to be font-related... Any ideas? I can hop on irc if you want... |
I got to my Ubuntu machine today, and I can reproduce what you describe without ever invoking a notebook. Just a single qtconsole, raise an error and invoke %debug, and I see the weird triangles. It happend with every invocation of %debug in the qtconsole, no need for multiple clients. And it's reproducible all the way back to 0.11 release, so it has nothing to do with recent unicode fixes like I thought. This is using PyQt4 (Ubuntu 10.04 LTS, qt4/pyqt4 from apt: PyQt4 4.7.2, Qt 4.6.2). As we discussed on IRC, this only affects PyQt, and not PySide, and the reason it appears new is that your PySide is 1.0.0, and PR #725 made the minimum PySide version 1.0.3, effectively switching your default from PySide to PyQt. |
Yup, you're right, I see it too. At least it's good to know it's an old problem we simply hadn't noticed and not something we broke recently... I'll open an issue and ping Evan about it. Thanks for the extra info! |
I added debug statements to the frontend, and I can see the difference between the normal traceback sent, and the one that's drawn wrong: null characters. Each triangle corresponds to a (\x00) char that is somehow added to the color-code only in the source, and only from ipdb. Raising the error with Whereas the same line, colored by ipdb is: It would appear that PySide just ignores the So this really seems like a bug in ipdb, just one that doesn't actually matter anywhere but in a pyqt-console. |
I should clarify, not a bug in ipdb, but rather a bug in pycolorize, which doesn't like unicode input. See the output of: In [20]: from IPython.utils import PyColorize
...: p = PyColorize.Parser()
In [21]: p.format('5', 'str')
Out[21]: '\x1b[0;36m5\x1b[0m\x1b[0;34m\x1b[0m\x1b[0m\n'
In [22]: p.format(u'5', 'str')
Out[22]: '\x1b[0;36m5\x1b[0m\x1b[0;31m\x00\x1b[0m\x1b[0;34m\x1b[0m\x1b[0m\n' |
Nailed, thanks! Now at least we know where the problem is coming from... I'll have a go at it now. |
Ah, easy fix: use StringIO instead of cStringIO. StringIO is unicode aware, but cStringIO is not. Thomas discovered this, and has fixed it in some other parts of the code, if I recall correctly. Should we just find/replace all cStringIOs (there are still a few)? |
Hey, On Mon, Sep 12, 2011 at 11:52 AM, Min RK
Yes!!! We'd been using the C version simply because that used to be thanks |
Back to actually discussing this PR, sorry for hijacking things with the other bug... This looks good and the right thing to do. Min, thanks for the work! I'll merge now. |
Ensures all replies from ipkernel are clean for json (not just oinfo), and guesses stdin.encoding before using sys.getdefaultencoding in json_clean.
Ensures all replies from ipkernel are clean for json (not just oinfo), and guesses stdin.encoding before using sys.getdefaultencoding in json_clean.
reopens #769 with further fixes
Ensures all replies from ipkernel are clean for json (not just oinfo), and guesses stdin.encoding before using sys.getdefaultencoding in json_clean.