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