Issue 33254: Have importlib.resources.contents() return an interable instead of an iterator (original) (raw)
Issue33254
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.
This issue has been migrated to GitHub: https://github.com/python/cpython/issues/77435
classification
Title: | Have importlib.resources.contents() return an interable instead of an iterator | ||
---|---|---|---|
Type: | behavior | Stage: | resolved |
Components: | Library (Lib) | Versions: | Python 3.8, Python 3.7 |
process
Status: | closed | Resolution: | fixed |
---|---|---|---|
Dependencies: | Superseder: | ||
Assigned To: | brett.cannon | Nosy List: | barry, brett.cannon, miss-islington |
Priority: | normal | Keywords: | patch |
Created on 2018-04-10 00:27 by brett.cannon, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Pull Requests | |||
---|---|---|---|
URL | Status | Linked | Edit |
PR 6467 | merged | brett.cannon,2018-04-13 22:13 | |
PR 6664 | merged | miss-islington,2018-04-30 18:32 |
Messages (5) | ||
---|---|---|
msg315155 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2018-04-10 00:27 |
If you look at https://github.com/python/cpython/blob/0f914b5b5f6ba186afd7112fc851c97247076f70/Lib/importlib/resources.py#L247 you will notice that the generator for importlib.resources.contents() return an empty list. While the intent was to have no values be returned by contents(), by virtue of being a generator that empty list is actually being returned as a value. | ||
msg315156 - (view) | Author: Barry A. Warsaw (barry) * ![]() |
Date: 2018-04-10 00:29 |
Note that this is in the case where a user is asking for the contents of a namespace package (which by definition, can't have resources). +1 on fixing this API wart. Will you @brett.cannon will submit a PR? I'll do a quick review and then backport the change to the standalone library. | ||
msg315170 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2018-04-10 15:05 |
I had to stare at it for a while since I knew it was for namespace packages and I'm so used to them returning a magical value to signal that fact, but then realize we don't even support namespace packages so it wasn't magical at all. ;) And yes, I'll do a PR and make you a reviewer probably this Friday. | ||
msg315959 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2018-04-30 18:31 |
New changeset 3ab9365dca8438f89b2060cd3eebe00606133dc4 by Brett Cannon in branch 'master': bpo-33254: do not return an empty list when asking for the contents of a namespace package (GH-6467) https://github.com/python/cpython/commit/3ab9365dca8438f89b2060cd3eebe00606133dc4 | ||
msg315961 - (view) | Author: miss-islington (miss-islington) | Date: 2018-04-30 19:30 |
New changeset 2e5fa38c5aaf7630c55ce6dfb8f79df6b3b86076 by Miss Islington (bot) in branch '3.7': bpo-33254: do not return an empty list when asking for the contents of a namespace package (GH-6467) https://github.com/python/cpython/commit/2e5fa38c5aaf7630c55ce6dfb8f79df6b3b86076 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:59 | admin | set | github: 77435 |
2018-04-30 19:44:12 | brett.cannon | set | status: open -> closedresolution: fixedstage: patch review -> resolved |
2018-04-30 19:30:33 | miss-islington | set | nosy: + miss-islingtonmessages: + |
2018-04-30 18:32:55 | miss-islington | set | pull_requests: + <pull%5Frequest6358> |
2018-04-30 18:31:54 | brett.cannon | set | messages: + |
2018-04-20 21:39:33 | brett.cannon | set | title: importlib.resources.contents() incorrectly yields an empty list -> Have importlib.resources.contents() return an interable instead of an iterator |
2018-04-13 22:13:29 | brett.cannon | set | keywords: + patchstage: test needed -> patch reviewpull_requests: + <pull%5Frequest6162> |
2018-04-10 15:05:09 | brett.cannon | set | messages: + |
2018-04-10 00:29:47 | barry | set | messages: + |
2018-04-10 00:27:02 | brett.cannon | create |
Supported by The Python Software Foundation,
Powered by Roundup
Copyright © 1990-2022, Python Software Foundation
Legal Statements