Comments (9)
pudb and pdb use literally the same code to implement user commands/variable assignments. It turns out that this is fine (and works in pudb and pdb) within the global scope, where variables are kept in a dict, but it very nearly can't be done inside a function, where variables are kept in the VM stack.
If you know otherwise, please let me know.
from pudb.
I see. It sounds like a hard problem.
from pudb.
As of Python 3.6.6 this seems to be resolved in pdb, it can change local variables.
from pudb.
Interesting. In that case, could you look into what pdb
does to make that happen? We should be able to just steal what they do.
from pudb.
I don't see any obvious changes to bdb.py or pdb.py related to this.
from pudb.
@kgabor I can't reproduce this. I use this script to test, on Python 3.7.3rc1.
def f():
i = 0
while i < 10:
i = i+1
print(i)
f()
I use pdb to step into f
until I'm in the middle of the loop, then say
(Pdb) s i = 20
> /home/andreas/tmp/zzz.py(5)f()
-> i = i+1
(Pdb) p i
1
which seems to contradict your statement.
from pudb.
I think this should be re-opened as it works in pdb.
When I test the code from #26 (comment), I can modify i
just fine:
$ python -m pdb zzz.py
> .../zzz.py(1)<module>()
-> def f():
(Pdb) n
> .../zzz.py(8)<module>()
-> f()
(Pdb) s
--Call--
> .../zzz.py(1)f()
-> def f():
(Pdb) n
> .../zzz.py(2)f()
-> i = 0
(Pdb) n
> .../zzz.py(4)f()
-> while i < 10:
(Pdb) n
> .../zzz.py(5)f()
-> i = i+1
(Pdb) n
-> print(i)
(Pdb) i
1
(Pdb) i = 20
(Pdb) i
20
(Pdb) n
20
> .../zzz.py(4)f()
-> while i < 10:
This is on Python 3.10.8.
from pudb.
It looks like pdb achieves this by making a copy of f_locals https://github.com/python/cpython/blob/aa8b58cb33826bd2b1a1de631ebcd6a5353eecb5/Lib/pdb.py#L299. Otherwise, frame.f_locals recomputes the locals every time it is accessed, wiping any changes that were made to it.
from pudb.
I have an in progress PR for a similar change for pudb to #571. It requires more testing, and also some cleaning up for the different shells.
from pudb.
Related Issues (20)
- remote debugging - Cannot disable application log message from garbling up the PuDB UI screen HOT 3
- Pudb UI Exception Encountered: Object 'A' appears to be a sequence, but does not behave like one: iteration over a 0-d tensor HOT 1
- Disable "view output" in remote debug HOT 1
- βI/O operation on closed fileβ when try with "Debugging from a separate terminal" HOT 12
- Error reported when exiting iPython and returning to UI on Mac OS X HOT 3
- Please make this marvel run well on a-Shell app for iPad HOT 1
- "Debugger instance already exists" when used in pytest HOT 5
- Greyscale Theme HOT 4
- New Release HOT 1
- Unable to use `--pdb --pdbcls=pudb.debugger:Debugger` with latest versions of urwid HOT 2
- telnetlib (used for remote debugger) is deprecated in Python 3.12 HOT 4
- Run to line in the same frame HOT 1
- Allow setting term size via env var HOT 1
- PUDB freezes at welcome screen HOT 2
- export PUDB_TTY=... not working HOT 1
- how can i see or get the current debugged file path?
- Ipython StartUp Script for pudb python shell. HOT 3
- remote debugging with telnet fails: a Debugger instance already exists HOT 2
- 2024.1 display clobbered with internal pudb [DEBUG] messages. HOT 11
- Variable ListBox crashes for long variables repr HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pudb.