Show More
@@ -1382,14 +1382,6 b' class InteractiveShell(SingletonConfigurable):' | |||
|
1382 | 1382 | found = False; obj = None; ospace = None; |
|
1383 | 1383 | ismagic = False; isalias = False; parent = None |
|
1384 | 1384 | |
|
1385 | # We need to special-case 'print', which as of python2.6 registers as a | |
|
1386 | # function but should only be treated as one if print_function was | |
|
1387 | # loaded with a future import. In this case, just bail. | |
|
1388 | if (oname == 'print' and not py3compat.PY3 and not \ | |
|
1389 | (self.compile.compiler_flags & __future__.CO_FUTURE_PRINT_FUNCTION)): | |
|
1390 | return {'found':found, 'obj':obj, 'namespace':ospace, | |
|
1391 | 'ismagic':ismagic, 'isalias':isalias, 'parent':parent} | |
|
1392 | ||
|
1393 | 1385 | # Look for the given name by splitting it in parts. If the head is |
|
1394 | 1386 | # found, then we look for all the remaining parts as members, and only |
|
1395 | 1387 | # declare success if we can find them all. |
@@ -1055,28 +1055,9 b' class VerboseTB(TBTools):' | |||
|
1055 | 1055 | etype, evalue = str, sys.exc_info()[:2] |
|
1056 | 1056 | etype_str, evalue_str = map(str, (etype, evalue)) |
|
1057 | 1057 | # ... and format it |
|
1058 |
|
|
|
1058 | return ['%s%s%s: %s' % (colors.excName, etype_str, | |
|
1059 | 1059 |
|
|
1060 | 1060 | |
|
1061 | if (not py3compat.PY3) and type(evalue) is types.InstanceType: | |
|
1062 | try: | |
|
1063 | names = [w for w in dir(evalue) if isinstance(w, str)] | |
|
1064 | except: | |
|
1065 | # Every now and then, an object with funny internals blows up | |
|
1066 | # when dir() is called on it. We do the best we can to report | |
|
1067 | # the problem and continue | |
|
1068 | _m = '%sException reporting error (object with broken dir())%s:' | |
|
1069 | exception.append(_m % (colors.excName, colorsnormal)) | |
|
1070 | etype_str, evalue_str = map(str, sys.exc_info()[:2]) | |
|
1071 | exception.append('%s%s%s: %s' % (colors.excName, etype_str, | |
|
1072 | colorsnormal, py3compat.cast_unicode(evalue_str))) | |
|
1073 | names = [] | |
|
1074 | for name in names: | |
|
1075 | value = text_repr(getattr(evalue, name)) | |
|
1076 | exception.append('\n%s%s = %s' % (indent, name, value)) | |
|
1077 | ||
|
1078 | return exception | |
|
1079 | ||
|
1080 | 1061 | def format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset): |
|
1081 | 1062 | """Formats the header, traceback and exception message for a single exception. |
|
1082 | 1063 |
@@ -116,7 +116,7 b' import traceback' | |||
|
116 | 116 | import types |
|
117 | 117 | import weakref |
|
118 | 118 | from importlib import import_module |
|
119 | ||
|
119 | from IPython.utils.py3compat import PY3 | |
|
120 | 120 | try: |
|
121 | 121 | # Reload is not defined by default in Python3. |
|
122 | 122 | reload |
@@ -124,7 +124,6 b' except NameError:' | |||
|
124 | 124 | from imp import reload |
|
125 | 125 | |
|
126 | 126 | from IPython.utils import openpy |
|
127 | from IPython.utils.py3compat import PY3 | |
|
128 | 127 | |
|
129 | 128 | #------------------------------------------------------------------------------ |
|
130 | 129 | # Autoreload functionality |
@@ -356,10 +355,7 b' def superreload(module, reload=reload, old_objects={}):' | |||
|
356 | 355 | try: |
|
357 | 356 | old_objects.setdefault(key, []).append(weakref.ref(obj)) |
|
358 | 357 | except TypeError: |
|
359 | # weakref doesn't work for all types; | |
|
360 | # create strong references for 'important' cases | |
|
361 | if not PY3 and isinstance(obj, types.ClassType): | |
|
362 | old_objects.setdefault(key, []).append(StrongRef(obj)) | |
|
358 | pass | |
|
363 | 359 | |
|
364 | 360 | # reload module |
|
365 | 361 | try: |
@@ -187,14 +187,6 b' def arg_split(s, posix=False, strict=True):' | |||
|
187 | 187 | command-line args. |
|
188 | 188 | """ |
|
189 | 189 | |
|
190 | # Unfortunately, python's shlex module is buggy with unicode input: | |
|
191 | # http://bugs.python.org/issue1170 | |
|
192 | # At least encoding the input when it's unicode seems to help, but there | |
|
193 | # may be more problems lurking. Apparently this is fixed in python3. | |
|
194 | is_unicode = False | |
|
195 | if (not py3compat.PY3) and isinstance(s, unicode): | |
|
196 | is_unicode = True | |
|
197 | s = s.encode('utf-8') | |
|
198 | 190 | lex = shlex.shlex(s, posix=posix) |
|
199 | 191 | lex.whitespace_split = True |
|
200 | 192 | # Extract tokens, ensuring that things like leaving open quotes |
@@ -217,7 +209,4 b' def arg_split(s, posix=False, strict=True):' | |||
|
217 | 209 | tokens.append(lex.token) |
|
218 | 210 | break |
|
219 | 211 | |
|
220 | if is_unicode: | |
|
221 | # Convert the tokens back to unicode. | |
|
222 | tokens = [x.decode('utf-8') for x in tokens] | |
|
223 | 212 | return tokens |
General Comments 0
You need to be logged in to leave comments.
Login now