X Tutup
The Wayback Machine - https://web.archive.org/web/20251114145235/https://github.com/python/cpython/pull/1756
Skip to content

Conversation

@mlouielu
Copy link
Contributor

@mlouielu mlouielu commented May 23, 2017

watch and awatch will detect value change and breakout, rwatch using dis module to get the file bytecode, with the lineno it can detect current line is load (read) or not.

@serhiy-storchaka serhiy-storchaka added the type-feature A feature request or enhancement label Dec 8, 2018
Copy link

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 19, 2022
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Jul 28, 2022
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Aug 28, 2022
@arhadthedev arhadthedev changed the title bpo-30429: bdb and pdb: Add watchpoint function gh-74614: bdb and pdb: Add watchpoint function Apr 15, 2023
@arhadthedev arhadthedev added the stdlib Standard Library Python modules in the Lib/ directory label Apr 15, 2023
@arhadthedev
Copy link
Member

The test.test_pdb.test_rwatch_command doctest fails:

Failed example:
    with PdbTestInput(['next',
                       'rwatch foo',
                       'continue',
                       'continue',
                       'continue',
                       'continue',
                       'continue',
                       'continue',
                       'continue',
                       'continue']):
        test_function()
Expected:
    > <doctest test.test_pdb.test_rwatch_command[0]>(3)test_function()
    -> foo = 10
    (Pdb) next
    > <doctest test.test_pdb.test_rwatch_command[0]>(4)test_function()
    -> type(foo)
    (Pdb) rwatch foo
    (Pdb) continue
    <BLANKLINE>
    read watchpoint 10:foo
[...]
Got:
    > <doctest test.test_pdb.test_rwatch_command[0]>(3)test_function()
    -> foo = 10
    (Pdb) next
    > <doctest test.test_pdb.test_rwatch_command[0]>(4)test_function()
    -> type(foo)
    (Pdb) rwatch foo
    (Pdb) continue
    <BLANKLINE>
    read watchpoint 4:foo
[...]

read watchpoint 4:foo comes from the freshly added functions:

self._do_watch(arg, 'read watchpoint')

cpython/Lib/pdb.py

Lines 673 to 683 in e1daed0

def _do_watch(self, arg, type):
if not arg:
# Print out all breakpoint
self.do_break(None)
return None
try:
eval(arg, self.curframe.f_locals)
except NameError:
self.error('No symbol "%s" in current context' % arg)
return None
self.set_watch(arg, self.curframe, type)

cpython/Lib/bdb.py

Lines 543 to 553 in e1daed0

def set_watch(self, var_name, var_frame, bptype):
try:
var_value = copy.copy(eval(var_name, var_frame.f_locals))
except NameError:
return 'Variable %s does not exist' % var_name
list = self.breaks.setdefault(bptype, [])
if var_name not in list:
list.append(var_name)
Breakpoint(None, None, var_name=var_name, var_value=var_value,
var_frame=var_frame, bptype=bptype)
return None

I cannot recognize what the problem is though.

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Apr 16, 2023
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review stale Stale PR or inactive for long period of time. stdlib Standard Library Python modules in the Lib/ directory type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

X Tutup