Compatibility with jupyter notebooks

This commit is contained in:
sizhky 2024-09-08 20:19:17 +05:30 committed by GitHub
parent f2c60de87f
commit 5ed3fb2463
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,6 +21,7 @@ if pycompat.PY2:
ipython_filename_pattern = re.compile('^<ipython-input-([0-9]+)-.*>$')
ansible_filename_pattern = re.compile(r'^(.+\.zip)[/|\\](ansible[/|\\]modules[/|\\].+\.py)$')
ipykernel_filename_pattern = re.compile('^/var/folders/.*/ipykernel_\d+/\d+.py$')
RETURN_OPCODES = {
'RETURN_GENERATOR', 'RETURN_VALUE', 'RETURN_CONST',
'INSTRUMENTED_RETURN_GENERATOR', 'INSTRUMENTED_RETURN_VALUE',
@ -74,6 +75,10 @@ def get_path_and_source_from_frame(frame):
if source is None:
ipython_filename_match = ipython_filename_pattern.match(file_name)
ansible_filename_match = ansible_filename_pattern.match(file_name)
ipykernel_filename_match = ipykernel_filename_pattern.match(file_name)
if ipykernel_filename_match:
import linecache
_, _, source, _ = linecache.cache.get(file_name)
if ipython_filename_match:
entry_number = int(ipython_filename_match.group(1))
try: