pdb is not working right
See original GitHub issueNow that code.interact()
seems to be working #853, I wondered if pdb could work too. It doesn’t.
The test page:
<script type="text/javascript"
src="https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js">
</script>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython_stdlib.js">
</script>
<body onload="brython({debug:1})">
<script type="text/python">
import pdb
pdb.set_trace()
</script>
</body>
And the output:
using indexedDB for stdlib modules cache brython.js:5198:36
Traceback (most recent call last):
module __main__ line 2
pdb.set_trace()
module pdb line 1608, in set_trace
pdb=Pdb()
module pdb line 144, in __init__
sys.audit("pdb.Pdb")
AttributeError: 'module' object has no attribute 'audit' brython.js:6120:9
Error: brython.js line 7674 > eval:41:354
$factory https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js line 7674 > eval:41
attr_error https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js:6654
$getattr https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js:6765
__init__11656 https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js line 9023 > Function:545
__call__ https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js:5553
<anonymous> self-hosted:911
factory https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js:5731
set_trace11758 https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js line 9023 > Function:8526
anonymous https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js line 5240 > Function:16
loop https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js:5240
idb_load https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js:5171
onsuccess https://cdn.jsdelivr.net/gh/brython-dev/brython@master/www/src/brython.js:5182
Neither does the new breakpoint()
.
using indexedDB for stdlib modules cache brython.js:5198:36
Traceback (most recent call last):
module __main__ line 1
breakpoint()
NameError: name 'breakpoint' is not defined
In CPython 3.7+, this is equivalent to pdb.set_trace()
, but it is configurable to use other debuggers. I suppose that in Brython it would not be unreasonable for breakpoint()
to use some other tool by default. Perhaps by embedding something like Brython’s web console into the page, or by using WebSockets or long polling with an external app like Clojurescript does.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
python - pdb.set_trace() not working - Stack Overflow
Thanks guys. Anthon and wim are right. I really did not import the standard pdb.py. Instead, I import another module having the same...
Read more >Troubleshoot Breakpoints in the Visual Studio Debugger
The PDB file is partially corrupted. Delete the file and run a clean build of the module to try to resolve the issue....
Read more >Python Debugging With Pdb
In this hands-on tutorial, you'll learn the basics of using pdb, Python's interactive source code debugger. Pdb is a great tool for tracking...
Read more >Problem debugging with pdb - Google Groups
two break points and they seem to save properly. I let the debugger continue through opening the test server, but when. I request...
Read more >Frequently Asked Questions - RCSB PDB
Warning You are using a web browser that we do not support. Our website will not work properly. Please update to a newer...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the latest commit above, the interactive debugger starts to work.
When I run this code:
I get the prompt with message (Pdb), and can enter simple commands (with this terrible Javascript popup…) like:
The issue is not yet closed - there are many other tests to do, and I didn’t implement
breakpoint()
- but it’s getting better…When I start an interactive session from the debugger in the terminal using the
interact
command, I can exit that and get back to the debugger with EOF (Ctrl-D in the terminal). But that’s a bookmark in the browser. So I kind of thought the cancel button in the javascript prompt would do it instead, but alas, it doesn’t. It seems to behave like an empty input.I even tried pasting in an EOF character using the clipboard. That’s how you have to do it in Jupyter when it runs interact in pdb, because it also runs in the browser. But this didn’t work for Brython either. I can’t type in
exit()
because that quits the whole program, debugger included.Can you distinguish a [Cancel] from an [OK] or enter in the prompt and treat it as an EOF?