|
17 | 17 | import os |
18 | 18 | import pathlib |
19 | 19 | import sys |
20 | | -import traceback |
21 | 20 |
|
22 | 21 | from google.colab import _history |
23 | 22 | from google.colab import _inspector |
|
27 | 26 | from ipykernel import compiler |
28 | 27 | from ipykernel import jsonutil |
29 | 28 | from ipykernel import zmqshell |
30 | | -from IPython.core import events |
31 | 29 | from IPython.core import interactiveshell |
32 | 30 | from IPython.core import oinspect |
33 | 31 | from IPython.utils import PyColorize |
@@ -90,17 +88,13 @@ def get_code_name(self, raw_code, code, number): |
90 | 88 | code_name = super().get_code_name(raw_code, code, number) |
91 | 89 | if code_name.endswith('.py'): |
92 | 90 | path = pathlib.Path(code_name) |
93 | | - code_name = f'/tmp/ipython-input-{path.name}' |
| 91 | + code_name = f'/tmp/ipython-input-{number}-{path.name}' |
94 | 92 | return code_name |
95 | 93 |
|
96 | 94 |
|
97 | 95 | class Shell(zmqshell.ZMQInteractiveShell): |
98 | 96 | """Shell with additional Colab-specific features.""" |
99 | 97 |
|
100 | | - def init_events(self): |
101 | | - self.events = events.EventManager(self, events.available_events) |
102 | | - self.events.register('pre_execute', self._clear_warning_registry) |
103 | | - |
104 | 98 | def init_inspector(self): |
105 | 99 | """Initialize colab's custom inspector.""" |
106 | 100 | self.inspector = _inspector.ColabInspector( |
@@ -238,34 +232,6 @@ def _getattr_property(obj, attrname): |
238 | 232 | # Nothing helped, fall back. |
239 | 233 | return getattr(obj, attrname) |
240 | 234 |
|
241 | | - def object_inspect(self, oname, detail_level=0): |
242 | | - info = self._ofind(oname) |
243 | | - |
244 | | - if info['found']: |
245 | | - try: |
246 | | - info = self._object_find(oname) |
247 | | - # We need to avoid arbitrary python objects remaining in info (and |
248 | | - # potentially being serialized below); `obj` itself needs to be |
249 | | - # removed, but retained for use below, and `parent` isn't used at all. |
250 | | - obj = info.pop('obj', '') |
251 | | - info.pop('parent', '') |
252 | | - result = self.inspector.info( |
253 | | - obj, oname, info=info, detail_level=detail_level |
254 | | - ) |
255 | | - except Exception as e: # pylint: disable=broad-except |
256 | | - self.kernel.log.info( |
257 | | - 'Exception caught during object inspection: ' |
258 | | - '{!r}\nTraceback:\n{}'.format( |
259 | | - e, ''.join(traceback.format_tb(sys.exc_info()[2])) |
260 | | - ) |
261 | | - ) |
262 | | - result = oinspect.InfoDict() |
263 | | - else: |
264 | | - result = super(Shell, self).object_inspect( |
265 | | - oname, detail_level=detail_level |
266 | | - ) |
267 | | - return result |
268 | | - |
269 | 235 | def run_cell_magic(self, magic_name, line, cell): |
270 | 236 | # We diverge from Jupyter behavior here: we want to allow cell magics with a |
271 | 237 | # nonempty line and no cell to execute, to unblock users executing a cell |
|
0 commit comments