##// END OF EJS Templates
fix at least some command-line unicode options
MinRK -
Show More
@@ -365,7 +365,14 b' class ArgParseConfigLoader(CommandLineConfigLoader):'
365 365
366 366 def _parse_args(self, args):
367 367 """self.parser->self.parsed_data"""
368 self.parsed_data, self.extra_args = self.parser.parse_known_args(args)
368 # decode sys.argv to support unicode command-line options
369 uargs = []
370 for a in args:
371 if isinstance(a, str):
372 # don't decode if we already got unicode
373 a = a.decode(sys.stdin.encoding)
374 uargs.append(a)
375 self.parsed_data, self.extra_args = self.parser.parse_known_args(uargs)
369 376
370 377 def _convert_to_config(self):
371 378 """self.parsed_data->self.config"""
@@ -158,7 +158,7 b' class InteractiveShell(Configurable, Magic):'
158 158 exit_now = CBool(False)
159 159 # Monotonically increasing execution counter
160 160 execution_count = Int(1)
161 filename = Str("<ipython console>")
161 filename = Unicode("<ipython console>")
162 162 ipython_dir= Unicode('', config=True) # Set to get_ipython_dir() in __init__
163 163
164 164 # Input splitter, to split entire cells of input into either individual
@@ -166,13 +166,13 b' class InteractiveShell(Configurable, Magic):'
166 166 input_splitter = Instance('IPython.core.inputsplitter.IPythonInputSplitter',
167 167 (), {})
168 168 logstart = CBool(False, config=True)
169 logfile = Str('', config=True)
170 logappend = Str('', config=True)
169 logfile = Unicode('', config=True)
170 logappend = Unicode('', config=True)
171 171 object_info_string_level = Enum((0,1,2), default_value=0,
172 172 config=True)
173 173 pdb = CBool(False, config=True)
174 174
175 profile = Str('', config=True)
175 profile = Unicode('', config=True)
176 176 prompt_in1 = Str('In [\\#]: ', config=True)
177 177 prompt_in2 = Str(' .\\D.: ', config=True)
178 178 prompt_out = Str('Out[\\#]: ', config=True)
@@ -1987,7 +1987,6 b' class InteractiveShell(Configurable, Magic):'
1987 1987 kw.setdefault('exit_ignore', False)
1988 1988
1989 1989 fname = os.path.abspath(os.path.expanduser(fname))
1990
1991 1990 # Make sure we have a .py file
1992 1991 if not fname.endswith('.py'):
1993 1992 warn('File must end with .py to be run using execfile: <%s>' % fname)
@@ -2004,6 +2003,11 b' class InteractiveShell(Configurable, Magic):'
2004 2003 # behavior of running a script from the system command line, where
2005 2004 # Python inserts the script's directory into sys.path
2006 2005 dname = os.path.dirname(fname)
2006
2007 if isinstance(fname, unicode):
2008 # execfile uses default encoding instead of filesystem encoding
2009 # so unicode filenames will fail
2010 fname = fname.encode(sys.getfilesystemencoding() or sys.getdefaultencoding())
2007 2011
2008 2012 with prepended_to_syspath(dname):
2009 2013 try:
@@ -19,7 +19,7 b' from IPython.external.qt import QtCore, QtGui'
19 19 from IPython.core.inputsplitter import IPythonInputSplitter, \
20 20 transform_ipy_prompt
21 21 from IPython.core.usage import default_gui_banner
22 from IPython.utils.traitlets import Bool, Str
22 from IPython.utils.traitlets import Bool, Str, Unicode
23 23 from frontend_widget import FrontendWidget
24 24 from styles import (default_light_style_sheet, default_light_syntax_style,
25 25 default_dark_style_sheet, default_dark_syntax_style,
@@ -57,19 +57,19 b' class IPythonWidget(FrontendWidget):'
57 57 # A command for invoking a system text editor. If the string contains a
58 58 # {filename} format specifier, it will be used. Otherwise, the filename will
59 59 # be appended to the end the command.
60 editor = Str('default', config=True)
60 editor = Unicode('default', config=True)
61 61
62 62 # The editor command to use when a specific line number is requested. The
63 63 # string should contain two format specifiers: {line} and {filename}. If
64 64 # this parameter is not specified, the line number option to the %edit magic
65 65 # will be ignored.
66 editor_line = Str(config=True)
66 editor_line = Unicode(config=True)
67 67
68 68 # A CSS stylesheet. The stylesheet can contain classes for:
69 69 # 1. Qt: QPlainTextEdit, QFrame, QWidget, etc
70 70 # 2. Pygments: .c, .k, .o, etc (see PygmentsHighlighter)
71 71 # 3. IPython: .error, .in-prompt, .out-prompt, etc
72 style_sheet = Str(config=True)
72 style_sheet = Unicode(config=True)
73 73
74 74 # If not empty, use this Pygments style for syntax highlighting. Otherwise,
75 75 # the style sheet is queried for Pygments style information.
@@ -33,7 +33,7 b' from IPython.core import ultratb'
33 33 from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
34 34 from IPython.frontend.terminal.ipapp import load_default_config
35 35
36 from IPython.utils.traitlets import Bool, Str, CBool
36 from IPython.utils.traitlets import Bool, Str, CBool, Unicode
37 37 from IPython.utils.io import ask_yes_no
38 38
39 39
@@ -62,7 +62,7 b" def kill_embedded(self,parameter_s=''):"
62 62 class InteractiveShellEmbed(TerminalInteractiveShell):
63 63
64 64 dummy_mode = Bool(False)
65 exit_msg = Str('')
65 exit_msg = Unicode('')
66 66 embedded = CBool(True)
67 67 embedded_active = CBool(True)
68 68 # Like the base class display_banner is not configurable, but here it
@@ -31,7 +31,7 b' from IPython.utils.terminal import toggle_set_term_title, set_term_title'
31 31 from IPython.utils.process import abbrev_cwd
32 32 from IPython.utils.warn import warn
33 33 from IPython.utils.text import num_ini_spaces
34 from IPython.utils.traitlets import Int, Str, CBool
34 from IPython.utils.traitlets import Int, Str, CBool, Unicode
35 35
36 36 #-----------------------------------------------------------------------------
37 37 # Utilities
@@ -59,9 +59,9 b' raw_input_original = raw_input'
59 59 class TerminalInteractiveShell(InteractiveShell):
60 60
61 61 autoedit_syntax = CBool(False, config=True)
62 banner = Str('')
63 banner1 = Str(default_banner, config=True)
64 banner2 = Str('', config=True)
62 banner = Unicode('')
63 banner1 = Unicode(default_banner, config=True)
64 banner2 = Unicode('', config=True)
65 65 confirm_exit = CBool(True, config=True)
66 66 # This display_banner only controls whether or not self.show_banner()
67 67 # is called when mainloop/interact are called. The default is False
@@ -71,8 +71,8 b' class TerminalInteractiveShell(InteractiveShell):'
71 71 display_banner = CBool(False) # This isn't configurable!
72 72 embedded = CBool(False)
73 73 embedded_active = CBool(False)
74 editor = Str(get_default_editor(), config=True)
75 pager = Str('less', config=True)
74 editor = Unicode(get_default_editor(), config=True)
75 pager = Unicode('less', config=True)
76 76
77 77 screen_length = Int(0, config=True)
78 78 term_title = CBool(False, config=True)
General Comments 0
You need to be logged in to leave comments. Login now