Changeset 388 for python/vendor/current/Lib/traceback.py
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Lib/traceback.py
r2 r388 65 65 name = co.co_name 66 66 _print(file, 67 ' File "%s", line %d, in %s' % (filename, lineno,name))67 ' File "%s", line %d, in %s' % (filename, lineno, name)) 68 68 linecache.checkcache(filename) 69 69 line = linecache.getline(filename, lineno, f.f_globals) … … 73 73 74 74 def format_tb(tb, limit = None): 75 """A shorthand for 'format_list(extract_ stack(f, limit))."""75 """A shorthand for 'format_list(extract_tb(tb, limit))'.""" 76 76 return format_list(extract_tb(tb, limit)) 77 77 … … 125 125 print_tb(tb, limit, file) 126 126 lines = format_exception_only(etype, value) 127 for line in lines[:-1]: 128 _print(file, line, ' ') 129 _print(file, lines[-1], '') 127 for line in lines: 128 _print(file, line, '') 130 129 131 130 def format_exception(etype, value, tb, limit = None): … … 168 167 # 169 168 # Clear these out first because issubtype(string1, SyntaxError) 170 # would throwanother exception and mask the original problem.169 # would raise another exception and mask the original problem. 171 170 if (isinstance(etype, BaseException) or 172 171 isinstance(etype, types.InstanceType) or … … 196 195 # only three spaces to account for offset1 == pos 0 197 196 lines.append(' %s^\n' % ''.join(caretspace)) 198 197 value = msg 199 198 200 199 lines.append(_format_final_exc_line(stype, value)) … … 213 212 try: 214 213 return str(value) 215 except: 216 return '<unprintable %s object>' % type(value).__name__ 214 except Exception: 215 pass 216 try: 217 value = unicode(value) 218 return value.encode("ascii", "backslashreplace") 219 except Exception: 220 pass 221 return '<unprintable %s object>' % type(value).__name__ 217 222 218 223 … … 242 247 """This is a shorthand for 'print_exception(sys.last_type, 243 248 sys.last_value, sys.last_traceback, limit, file)'.""" 249 if not hasattr(sys, "last_type"): 250 raise ValueError("no last exception") 244 251 if file is None: 245 252 file = sys.stderr
Note:
See TracChangeset
for help on using the changeset viewer.