##// END OF EJS Templates
Merge pull request #10136 from srinivasreddy/dead_people...
Matthias Bussonnier -
r23107:21618370 merge
parent child Browse files
Show More
@@ -1382,14 +1382,6 b' class InteractiveShell(SingletonConfigurable):'
1382 found = False; obj = None; ospace = None;
1382 found = False; obj = None; ospace = None;
1383 ismagic = False; isalias = False; parent = None
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 # Look for the given name by splitting it in parts. If the head is
1385 # Look for the given name by splitting it in parts. If the head is
1394 # found, then we look for all the remaining parts as members, and only
1386 # found, then we look for all the remaining parts as members, and only
1395 # declare success if we can find them all.
1387 # declare success if we can find them all.
@@ -1055,27 +1055,8 b' class VerboseTB(TBTools):'
1055 etype, evalue = str, sys.exc_info()[:2]
1055 etype, evalue = str, sys.exc_info()[:2]
1056 etype_str, evalue_str = map(str, (etype, evalue))
1056 etype_str, evalue_str = map(str, (etype, evalue))
1057 # ... and format it
1057 # ... and format it
1058 exception = ['%s%s%s: %s' % (colors.excName, etype_str,
1058 return ['%s%s%s: %s' % (colors.excName, etype_str,
1059 colorsnormal, py3compat.cast_unicode(evalue_str))]
1059 colorsnormal, py3compat.cast_unicode(evalue_str))]
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
1060
1080 def format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset):
1061 def format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset):
1081 """Formats the header, traceback and exception message for a single exception.
1062 """Formats the header, traceback and exception message for a single exception.
@@ -116,7 +116,7 b' import traceback'
116 import types
116 import types
117 import weakref
117 import weakref
118 from importlib import import_module
118 from importlib import import_module
119
119 from IPython.utils.py3compat import PY3
120 try:
120 try:
121 # Reload is not defined by default in Python3.
121 # Reload is not defined by default in Python3.
122 reload
122 reload
@@ -124,7 +124,6 b' except NameError:'
124 from imp import reload
124 from imp import reload
125
125
126 from IPython.utils import openpy
126 from IPython.utils import openpy
127 from IPython.utils.py3compat import PY3
128
127
129 #------------------------------------------------------------------------------
128 #------------------------------------------------------------------------------
130 # Autoreload functionality
129 # Autoreload functionality
@@ -356,10 +355,7 b' def superreload(module, reload=reload, old_objects={}):'
356 try:
355 try:
357 old_objects.setdefault(key, []).append(weakref.ref(obj))
356 old_objects.setdefault(key, []).append(weakref.ref(obj))
358 except TypeError:
357 except TypeError:
359 # weakref doesn't work for all types;
358 pass
360 # create strong references for 'important' cases
361 if not PY3 and isinstance(obj, types.ClassType):
362 old_objects.setdefault(key, []).append(StrongRef(obj))
363
359
364 # reload module
360 # reload module
365 try:
361 try:
@@ -187,14 +187,6 b' def arg_split(s, posix=False, strict=True):'
187 command-line args.
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 lex = shlex.shlex(s, posix=posix)
190 lex = shlex.shlex(s, posix=posix)
199 lex.whitespace_split = True
191 lex.whitespace_split = True
200 # Extract tokens, ensuring that things like leaving open quotes
192 # Extract tokens, ensuring that things like leaving open quotes
@@ -216,8 +208,5 b' def arg_split(s, posix=False, strict=True):'
216 # couldn't parse, get remaining blob as last token
208 # couldn't parse, get remaining blob as last token
217 tokens.append(lex.token)
209 tokens.append(lex.token)
218 break
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 return tokens
212 return tokens
General Comments 0
You need to be logged in to leave comments. Login now