This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2017年08月11日 15:21 by syncosmic, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 3077 | merged | syncosmic, 2017年08月11日 19:00 | |
| Messages (8) | |||
|---|---|---|---|
| msg300167 - (view) | Author: syncosmic (syncosmic) * | Date: 2017年08月11日 15:21 | |
Issue 21947 informed the `dis` module about the `gi_code` attribute, which stores code objects for generator objects. This allows inspection of generator objects, not just functions which return them. However, asynchronous generator objects use `ag_code` and coroutine objects use `cr_code`, so dis raises a TypeError on them. I'm making a pull request to extend the generator behavior to async generators and coroutines. Credit to Luciano Ramalho: I tripped over this at his (great) concurrency workshop at PyBay 2017 and he identified exactly what was happening and suggested a patch. |
|||
| msg300184 - (view) | Author: Mariatta (Mariatta) * (Python committer) | Date: 2017年08月11日 22:32 | |
Adding Serhiy and Nick who worked on these parts of CPython. |
|||
| msg300188 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2017年08月12日 04:36 | |
Is this a bug fix or a new feature? Adding support of generators in issue21947 was a new feature and was not backported to older versions. |
|||
| msg300194 - (view) | Author: syncosmic (syncosmic) * | Date: 2017年08月12日 10:39 | |
Hm--either/both? I encountered it as a bug ("dis works on my generator object and my async generator function, why does it break on my async generator object?") but strictly speaking it's a new feature (just as issue21947 was). To my mind, adding this level of indirection (finding the code object) for generators was a bit of a design decision but once it's in for generators it should be in for async generators and coroutines by analogy.
|
|||
| msg300200 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2017年08月12日 15:18 | |
While I agree the line is blurry, extending automatic disassembly to cover new types is currently still considered a new feature in the dis module rather than a bug in the addition of those new types to the language. Whether or not that's the *right* policy, or if we should consider tweaking it so that oversights in `dis` and `inspect` are treated as bugs in the addition of affected types, would be a question for python-dev (fortunately, the new cherry-pick based workflow means the current PR review can proceed independently of that question). |
|||
| msg300207 - (view) | Author: syncosmic (syncosmic) * | Date: 2017年08月12日 21:33 | |
Makes sense. I'll update the PR in a bit, and if anyone is hitting this repeatedly and thinks it should be added to 3.6 they can advocate for a policy change in the maintaining-consistency-with-previous-new-features corner case. Thanks, all! |
|||
| msg300470 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2017年08月18日 02:29 | |
New changeset fe2b56ab9212c1cf19c48b848fa60f7f201c366f by Nick Coghlan (syncosmic) in branch 'master': bpo-31183: `dis` now handles coroutines & async generators (GH-3077) https://github.com/python/cpython/commit/fe2b56ab9212c1cf19c48b848fa60f7f201c366f |
|||
| msg300579 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2017年08月19日 11:09 | |
Thanks for the patch! Issue 31230 is a follow-up issue looking at whether or not we should define a general "__code__" attribute as a general purpose introspection protocol for disassembly support (amongst other generalisations of state introspection support for async operations). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:50 | admin | set | github: 75366 |
| 2017年08月19日 11:09:37 | ncoghlan | set | messages: + msg300579 |
| 2017年08月19日 11:07:30 | ncoghlan | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017年08月18日 02:29:23 | ncoghlan | set | messages: + msg300470 |
| 2017年08月12日 21:33:48 | syncosmic | set | messages: + msg300207 |
| 2017年08月12日 15:18:14 | ncoghlan | set | messages:
+ msg300200 versions: - Python 3.6 |
| 2017年08月12日 10:39:17 | syncosmic | set | messages: + msg300194 |
| 2017年08月12日 04:36:17 | serhiy.storchaka | set | messages: + msg300188 |
| 2017年08月11日 22:32:59 | Mariatta | set | nosy:
+ Mariatta, serhiy.storchaka, ncoghlan messages: + msg300184 stage: patch review |
| 2017年08月11日 19:00:07 | syncosmic | set | pull_requests: + pull_request3114 |
| 2017年08月11日 15:21:31 | syncosmic | create | |