| 234 | return s |
| 235 | |
| 236 | def format(self, limit=None, most_recent_first=False): |
| 237 | lines = [] |
| 238 | if limit is not None: |
| 239 | if limit > 0: |
| 240 | frame_slice = self[-limit:] |
| 241 | else: |
| 242 | frame_slice = self[:limit] |
| 243 | else: |
| 244 | frame_slice = self |
| 245 | |
| 246 | if most_recent_first: |
| 247 | frame_slice = reversed(frame_slice) |
| 248 | for frame in frame_slice: |
| 249 | lines.append(' File "%s", line %s' |
| 250 | % (frame.filename, frame.lineno)) |
| 251 | line = linecache.getline(frame.filename, frame.lineno).strip() |
| 252 | if line: |
| 253 | lines.append(' %s' % line) |
| 254 | return lines |
| 255 | |
| 256 | |
| 257 | def get_object_traceback(obj): |