Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-124552 : Improve the accuracy of possible breakpoint check in bdb#124553

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@gaogaotiantian
Copy link
Member

@gaogaotiantiangaogaotiantian commentedSep 25, 2024
edited by bedevere-appbot
Loading

Now we check whether the line number is in the code object withco_lines() so we can have an accurate answer.

A bug needs to be fixed for generators. This is not caused by the new feature, but exposed. I put those together because the changes are very small. I can separate those if that's desired.

@gaogaotiantiangaogaotiantian changed the titleImprove the accuracy of possible breakpoint check in bdbgh-124552 : Improve the accuracy of possible breakpoint check in bdbSep 25, 2024
@iritkatriel
Copy link
Member

This needs a test.

Lib/bdb.py Outdated
Comment on lines 298 to 300
self.code_lineno[code]=set()
for_,_,linenoincode.co_lines():
self.code_lineno[code].add(lineno)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self.code_lineno[code]=set()
for_,_,linenoincode.co_lines():
self.code_lineno[code].add(lineno)
self.code_lineno[code]=set([lnofor_,_,lnoincode.co_lines()])

@gaogaotiantian
Copy link
MemberAuthor

Do you think a test that directly testsbreak_anywhere intest_bdb would work? It's a public documented API. Checking whether the dispatch function stopped would be a bit more complicated.

@gaogaotiantian
Copy link
MemberAuthor

I added a test forbreak_anywhere. Also I used the generator forset() instead of a list.

@terryjreedy
Copy link
Member

I am testing this with IDLE's bdb-based debugger now.

@terryjreedy
Copy link
Member

No (new) problems found. Breakpoints at top level and in def still work.

@gaogaotiantian
Copy link
MemberAuthor

Thanks@terryjreedy for confirming this.#124533 might be another interesting one to test.

Lib/bdb.py Outdated
returnFalse
ifcodenotinself.code_lineno:
self.code_lineno[code]=set(linenofor_,_,linenoincode.co_lines())
returnlinenoinself.code_lineno[frame.f_code]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
returnlinenoinself.code_lineno[frame.f_code]
returnlinenoinself.code_lineno[code]

Lib/bdb.py Outdated
self.frame_returning=None
self.trace_opcodes=False
self.enterframe=None
self.code_lineno=weakref.WeakKeyDictionary()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self.code_lineno=weakref.WeakKeyDictionary()
self.code_linenos=weakref.WeakKeyDictionary()

Lib/bdb.py Outdated
raiseNotImplementedError("subclass of bdb must implement do_clear()")

defbreak_anywhere(self,frame):
"""Return True if there is any breakpoint for frame's filename.
Copy link
Member

Choose a reason for hiding this comment

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

this comment needs updating (it's not just filename now).

gaogaotiantianand others added2 commitsOctober 4, 2024 19:04
…nQKNM.rstCo-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
ifself.stopframeandframe.f_code.co_flags&GENERATOR_AND_COROUTINE_FLAGS:
# It's possible to trigger a StopIteration exception in
# the caller so we must set the trace function in the caller
self._set_caller_tracefunc(frame)
Copy link
Member

Choose a reason for hiding this comment

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

how is this related to this PR?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

There is a hidden bug which was exposed by the change ofbreak_anywhere. There's a test case ofbdb testing raisingStopIteration in a generator. It passed becausebreak_anywhere always returnTrue when the function was defined in the same file, which always sets the trace function on the caller because it is in the same file. That coincidence hide the bug where returning from a generator should stop in the caller. There's a similar call in line 177 - that's for the normal return case from#118979 - it's also my fix to a similar case.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@iritkatrieliritkatrieliritkatriel approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@gaogaotiantian@iritkatriel@terryjreedy

[8]ページ先頭

©2009-2025 Movatter.jp