-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
fix bpo-31183: allowing dis
to disassemble async generator and coroutine objects
#3077
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ff0d6c2
bpo-31183: dis can disassemble async gens/coros
syncosmic 1d08a7c
bpo-31183: dis unit tests for async gen/coro
syncosmic 6700a24
bpo-31183: add async gens/coros to dis doc
syncosmic 45f693c
Fixed whitespace issues (I hope)
syncosmic ec7d10a
Fixed brittleness in test_source_line_in_disassembly.
syncosmic 33523c5
avoid coroutine warning by explicitly closing coroutine; clean up
syncosmic 7b3d19a
fix TypeError if compiled coroutine is actually run
syncosmic f3a9055
improve docstrings
syncosmic 7f92546
clarify control flow and improve comments
syncosmic edaffa6
add versionchanged tags to doc
syncosmic 32d9d5b
expand one more docstring
syncosmic 42dd060
added blurb
syncosmic 16b1d23
fix whitespace in doc (TODO: improve my workflow)
syncosmic b969705
cleaned up docs and comments per ncoghlan
syncosmic df4dc64
fix docstring fomatting, tweak line number extraction
syncosmic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Library/2017-08-13-09-17-01.bpo-31183.-2_YGj.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
`dis` now works with asynchronous generator and coroutine objects. Patch by | ||
George Collins based on diagnosis by Luciano Ramalho. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I don't think we should hold up this PR for it, this does make we wonder if we should just be exposing a
__code__
attribute on all of these types.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struck me as well, so I did a little digging on the history and context. It looks as though
gi_code
was added to generators in bpo-1473257. At this time, function bytecode was still stored inf.func_code
, sogi_code
was a clear analogy.Then
func_code
was changed in 3.0 to__code__
as part of thef.func_X
tof.__X__
renaming. The 3.0 whatsnew explained that the purpose of this change was to "free up [thef.func_X
] names in the function attribute namespace for user-defined attributes". But this wasn't done for the analogous code object in generators. On a quick look, I didn't find any discussion of this at the time, but that doesn't mean there wasn't any.It seems, then, that there are two questions now:
1 seems easier to answer, although that kind of breaking change was probably more in the spirit of 3.0 than 3.7. I have a couple of dim thoughts on 2 but I'll save them for possible later discussion elsewhere.
This also raises the question of whether at least some of the other
[gi|ag|cr]_X
attributes should be dundered and/or homogenized.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least some of the others are deliberately different because they refer to slightly different things (e.g. cr_await vs gi_yieldfrom).
Anyway, I've added a note about that to the refactoring issue: https://bugs.python.org/issue31197#msg300291