Show More
@@ -41,13 +41,19 b' from IPython.utils.traitlets import Integer, CBool, Unicode' | |||||
41 | def get_default_editor(): |
|
41 | def get_default_editor(): | |
42 | try: |
|
42 | try: | |
43 | ed = os.environ['EDITOR'] |
|
43 | ed = os.environ['EDITOR'] | |
|
44 | if not py3compat.PY3: | |||
|
45 | ed = ed.decode() | |||
|
46 | return ed | |||
44 | except KeyError: |
|
47 | except KeyError: | |
45 | if os.name == 'posix': |
|
48 | pass | |
46 | ed = 'vi' # the only one guaranteed to be there! |
|
49 | except UnicodeError: | |
47 | else: |
|
50 | warn("$EDITOR environment variable is not pure ASCII. Using platform " | |
48 | ed = 'notepad' # same in Windows! |
|
51 | "default editor.") | |
49 | return ed |
|
52 | ||
50 |
|
53 | if os.name == 'posix': | ||
|
54 | return 'vi' # the only one guaranteed to be there! | |||
|
55 | else: | |||
|
56 | return 'notepad' # same in Windows! | |||
51 |
|
57 | |||
52 | def get_pasted_lines(sentinel, l_input=py3compat.input): |
|
58 | def get_pasted_lines(sentinel, l_input=py3compat.input): | |
53 | """ Yield pasted lines until the user enters the given sentinel value. |
|
59 | """ Yield pasted lines until the user enters the given sentinel value. |
@@ -1024,7 +1024,11 b' class Unicode(TraitType):' | |||||
1024 | if isinstance(value, py3compat.unicode_type): |
|
1024 | if isinstance(value, py3compat.unicode_type): | |
1025 | return value |
|
1025 | return value | |
1026 | if isinstance(value, bytes): |
|
1026 | if isinstance(value, bytes): | |
1027 | return py3compat.unicode_type(value) |
|
1027 | try: | |
|
1028 | return value.decode('ascii', 'strict') | |||
|
1029 | except UnicodeDecodeError: | |||
|
1030 | msg = "Could not decode {!r} for unicode trait '{}' of {} instance." | |||
|
1031 | raise TraitError(msg.format(value, self.name, class_of(obj))) | |||
1028 | self.error(obj, value) |
|
1032 | self.error(obj, value) | |
1029 |
|
1033 | |||
1030 |
|
1034 |
General Comments 0
You need to be logged in to leave comments.
Login now