-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BLD: ipython_directive, handle non-ascii execution results #6185
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
Conversation
@y-p This looks nice! And in any case, the docs build on Windows. But yet some possible quirks, I commented inline. For the faster doc building, will try out later (no time anymore today). |
|
||
data = b'word,length\nTr\xc3\xa4umen,7\nGr\xc3\xbc\xc3\x9fe,5'.decode('utf8').encode('latin-1') | ||
data = b'word,length\nTr\xc3\xa4umen,7\nGr\xc3\xbc\xc3\x9fe,5' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible that it is still utf-8, and not latin? See your previous commit where you changed this: 3dbb9ea. So now it's unicode tried to show as latin?
Because now I get:
word length
0 TrÇÏumen 7
1 GrǬÇ?e 5
However, if I change it back to the original latin-1 (what you get from b'word,length\nTr\xc3\xa4umen,7\nGr\xc3\xbc\xc3\x9fe,5'.decode('utf8').encode('latin-1')
), it's also not correct:
word length
0 Tr�umen 7
1 Gr�áe 5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, good catch.
@y-p Seems you did some of the wishlist items in #5530 (comment) yourself, nice! @jorisvandenbossche asked me in #5530 (comment) to try on py3. Tried it on win+py3, I get an instant fail. Since this PR is about sphinx speedup, section building and non-ascii handling on platforms such as Windows, I think the py3 compat should be done in a new PR after this one is merged. |
try: | ||
encoding = [options.get('output_encoding', 'utf8')] | ||
self.shell.output_encoding = encoding | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this except ever reached? I mean, does the try block ever fail? It's just putting the encoding, not yet really encoding it, or do I see it wrong?
Because I supposed I would get such a warning if I removed the :output_encoding: 'latin1'
, but that's not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remnant of an earlier version that accepted multiple encodings to try in order, and
had to use eval because of limitations in ReST directives. will fix.
The bad output in the cell is the result of pprint_thing used by the repr, and it''s output
That's the problem. I've changed things accordingly. |
Hmm, it's still the same. But the docs build, so that's the most important for me if the output looks nice on linux. And I think you forgot to put in the commit that changes io.rst (the |
That's not required. So this is nicer code that's no worse then the previous attempt? |
Indeed, I can confirm this is nicer code for the same (incorrect on windows but building) result :-) What is the addition of |
BTW, I forgot almost I tested it, and it does matter (as is what I would understand from the code). Without specifying |
I inserted a decoding step on all write to stdout from code executing You may get |
BLD: ipython_directive, handle non-ascii execution results
@y-p Do you find this good enough to push upstream? If you don't have time, I can try to do this. |
@jorisvandenbossche I think this is a clean solution to the non-utf8
output problem we discussed, specifically the example in io.rst.
This PR should produce the right output on windows and be more amenable
to py3 compat work too. If you confirm that it's good I feel this is clean enough
to try and get upstream, completing the upstreaming effort.
related #5530, #5925 (comment)