Writing unicode characters to a log file. (IPython 0.10.2.git) #249

Merged
2 commits merged into from Mar 13, 2011

Conversation

Projects
None yet
4 participants

TvrtkoM commented Jan 21, 2011

Example:

When trying to log a statements like this during logging:

In [2]: logstart -o logtest.py over
In [3]: t = 'žćčšđ'
...
UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-9: ordinal not in range(128)

The supplied patch fixes the problem. At least temporary.

Also, changed the log header to contain the encoding definition for the source file.
Useful for rerunning the log file outside IPython.

TvrtkoM added some commits Jan 21, 2011

Encode data with system default encoding before writing to log file.
This enables writing non-ascii characters to be written in log file during
logging session.
Owner

takluyver commented Jan 26, 2011

Looking at the code, output data is written separately. It's not easy to get unicode output in Python 2.x (assuming we're limited to reprs produced by the interpreter, not print statements), but it is possible: define a class, replace its __name__ with a unicode character, and ask for it. So we should probably encode odata too, just to be on the safe side.

Owner

fperez commented Mar 13, 2011

Adding encoding also to output and merging for 0.10.2 release. Many thanks!

@minrk minrk added this to the old milestone Apr 10, 2014

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment