From ae7a33df9ff740cfd6faa33bd2f77ff11a4c706a 2007-12-12 19:32:33 From: vivainio Date: 2007-12-12 19:32:33 Subject: [PATCH] add sys.setdefaultencoding() call after a patch by 'pan'. ChangeLogs --- diff --git a/IPython/iplib.py b/IPython/iplib.py index 4c5d9b2..07269bc 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.3 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 2885 2007-12-07 10:59:06Z vivainio $ +$Id: iplib.py 2889 2007-12-12 19:32:33Z vivainio $ """ #***************************************************************************** @@ -79,6 +79,16 @@ import IPython.prefilter as prefilter import IPython.shadowns # Globals +# make converting between str and unicode easy, so str() will work most of the +# time + +try: + sys.setappdefaultencoding(sys.stdin.encoding or 'ascii') +except: + # Many python versions don't have sys.setappdefaultencoding + reload(sys) + sys.setdefaultencoding(sys.stdin.encoding or 'ascii') + # store the builtin raw_input globally, and use this always, in case user code # overwrites it (like wx.py.PyShell does) raw_input_original = raw_input @@ -1911,7 +1921,7 @@ want to merge them back into the new files.""" % locals() # this allows execution of indented pasted code. It is tempting # to add '\n' at the end of source to run commands like ' a=1' # directly, but this fails for more complicated scenarios - source=source.encode(self.stdin_encoding) + source = str(source) if source[:1] in [' ', '\t']: source = 'if 1:\n%s' % source diff --git a/doc/ChangeLog b/doc/ChangeLog index e8587ad..ef174ea 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,13 @@ +2007-12-12 Ville Vainio + + * genutils.py (abbrev_cwd): Terminal title now shows 2 levels of current + directory. + + * iplib.py: We now set system default encoding to sys.stdin.encoding with + sys.setdefaultencoding, after a patch by 'pan'. This makes str() calls that + IPython still has implicitly work. This should be removed when such calls + are cleaned. + 2007-12-12 Fernando Perez * IPython/Shell.py (_select_shell): add support for controlling @@ -5,6 +15,19 @@ having to modify MPL config files. Added unit tests for this feature, though manual/docs update is still pending, will do later. +2007-12-11 Ville Vainio + + * ext_rescapture.py: var = !cmd is no longer verbose (to facilitate + use in scripts) + +2007-12-07 Ville Vainio + + * iplib.py, ipy_profile_sh.py: Do not escape # on command lines + anymore (to \#) - even if it is a comment char that is implicitly + escaped in some unix shells in interactive mode, it is ok to leave + it in IPython as such. + + 2007-12-01 Robert Kern * IPython/ultraTB.py (findsource): Improve the monkeypatch to @@ -39,6 +62,7 @@ readline_omit__names setting. 2007-11-08 Ville Vainio + * ipy_completers.py (import completer): assume 'xml' module exists. Do not add every module twice anymore. Closes #196.