Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipdb broken in jupyter notebook on windows 10 #13556

Open
axil opened this issue Feb 26, 2022 · 2 comments
Open

ipdb broken in jupyter notebook on windows 10 #13556

axil opened this issue Feb 26, 2022 · 2 comments

Comments

@axil
Copy link

axil commented Feb 26, 2022

After a recent update, ipdb does not show current line and context in jupyter notebook anymore. The 'l' command works fine, though. So I have to run 'l' after every single 'n' manually.

def f():
    import ipdb; ipdb.set_trace()
    print('hi')
f()

image

image

I've traced down the problem and the source is the direction of the slashes. The function format_stack_entry receives a frame object with mixed slashes: <frame at 0x000001F092B6A388, file 'C:\Users\ASUS\AppData\Local\Temp/ipykernel_20044/714112756.py', line 2, code f>

Then the 'l' command (do_list) queries linecache with this mixed slashes and succeeds, while the print_stack_entry canonizes the filename so that it looks like 'C:\Users\ASUS\AppData\Local\Temp\ipykernel_20044\714112756.py' (note two last slashes are now forward slashes, not backslashes) — and linecache returns an empty list.

Did not dig deeper, but this quick and dirty workaround helps:

--- debugger.py~        2022-02-26 17:51:36.823790800 +0700
+++ debugger.py 2022-02-26 17:51:48.077555800 +0700
@@ -571,7 +571,7 @@
         ret.append(return_value)

         #s = filename + '(' + `lineno` + ')'
-        filename = self.canonic(frame.f_code.co_filename)
+        filename = frame.f_code.co_filename
         link = tpl_link % py3compat.cast_unicode(filename)

         if frame.f_code.co_name:

I ran git blame against IPython/core/debugger.py and this particular line is >10 years old, so it is definitely not the source of the problem, but this fix works for me.

@axil axil changed the title ipdb broken in jupyter on windows 10 ipdb broken in jupyter notebook on windows 10 Feb 26, 2022
@axil
Copy link
Author

axil commented Feb 26, 2022

Checked with python3.6 and python3.9.

Pip freeze for python3.9 is like this:
argon2-cffi==21.1.0
astor==0.8.1
attrs==21.2.0
autopep8==1.6.0
backcall==0.2.0
bleach==4.1.0
cffi==1.14.6
colorama==0.4.4
debugpy==1.4.3
decorator==5.0.9
defusedxml==0.7.1
entrypoints==0.3
ipdb==0.13.9
ipykernel==6.4.0
ipython==7.27.0
ipython-genutils==0.2.0
jedi==0.18.0
Jinja2==3.0.1
jsonschema==3.2.0
jupyter-client==7.0.2
jupyter-core==4.7.1
jupyterlab-pygments==0.1.2
MarkupSafe==2.0.1
matplotlib-inline==0.1.3
mistune==0.8.4
mypy==0.931
mypy-extensions==0.4.3
nb-mypy==1.0.2
nbclient==0.5.4
nbconvert==6.1.0
nbformat==5.1.3
nest-asyncio==1.5.1
notebook==6.4.3
numpy==1.21.2
packaging==21.0
pandocfilters==1.4.3
parso==0.8.2
pickleshare==0.7.5
prometheus-client==0.11.0
prompt-toolkit==3.0.20
pycodestyle==2.8.0
pycparser==2.20
Pygments==2.10.0
pyparsing==2.4.7
pyrsistent==0.18.0
python-dateutil==2.8.2
pywin32==301
pywinpty==1.1.4
pyzmq==22.2.1
Send2Trash==1.8.0
six==1.16.0
terminado==0.12.1
testpath==0.5.0
toml==0.10.2
tomli==2.0.1
tornado==6.1
traitlets==5.1.0
typing_extensions==4.1.1
wcwidth==0.2.5
webencodings==0.5.1

Python 3.9.7 (64bit). Windows 10 x64 Home Edition.

@MrMino
Copy link
Member

MrMino commented Feb 27, 2022

I don't have Win10 on hand right now so if someone else could repro this with the same environment it would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants