|
29 | 29 | import os |
30 | 30 | import pkgutil |
31 | 31 | import pydoc |
| 32 | +import re |
32 | 33 | import shlex |
33 | 34 | import subprocess |
34 | 35 | import sys |
@@ -133,6 +134,9 @@ def showsyntaxerror(self, filename=None): |
133 | 134 | # Stuff in the right filename and right lineno |
134 | 135 | if not py3: |
135 | 136 | lineno -= 1 |
| 137 | + if re.match(r'<bpython-input-\d+>', filename): |
| 138 | + filename = '<input>' |
| 139 | + # strip linecache line number |
136 | 140 | value = SyntaxError(msg, (filename, lineno, offset, line)) |
137 | 141 | sys.last_value = value |
138 | 142 | list = traceback.format_exception_only(type, value) |
@@ -149,9 +153,14 @@ def showtraceback(self): |
149 | 153 | sys.last_traceback = tb |
150 | 154 | tblist = traceback.extract_tb(tb) |
151 | 155 | del tblist[:1] |
152 | | - # Set the right lineno (encoding header adds an extra line) |
153 | | - if not py3: |
154 | | - for i, (fname, lineno, module, something) in enumerate(tblist): |
| 156 | + |
| 157 | + for i, (fname, lineno, module, something) in enumerate(tblist): |
| 158 | + # strip linecache line number |
| 159 | + if re.match(r'<bpython-input-\d+>', fname): |
| 160 | + fname = '<input>' |
| 161 | + tblist[i] = (fname, lineno, module, something) |
| 162 | + # Set the right lineno (encoding header adds an extra line) |
| 163 | + if not py3: |
155 | 164 | if fname == '<input>': |
156 | 165 | tblist[i] = (fname, lineno - 1, module, something) |
157 | 166 |
|
|