Skip to content
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

#257: save list in memory to avoid reusing exhausted iterator #258

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packaging/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _py_interpreter_range(py_version):
def compatible_tags(
python_version=None, # type: Optional[PythonVersion]
interpreter=None, # type: Optional[str]
platforms=None, # type: Optional[Iterator[str]]
platforms=None, # type: Optional[Iterable[str]]
):
# type: (...) -> Iterator[Tag]
"""
Expand All @@ -328,8 +328,7 @@ def compatible_tags(
"""
if not python_version:
python_version = sys.version_info[:2]
if not platforms:
platforms = _platform_tags()
platforms = list(platforms or _platform_tags())
for version in _py_interpreter_range(python_version):
for platform_ in platforms:
yield Tag(version, "none", platform_)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,12 +923,15 @@ def test_default_interpreter(self):
]

def test_default_platforms(self, monkeypatch):
monkeypatch.setattr(tags, "_platform_tags", lambda: ["plat"])
monkeypatch.setattr(tags, "_platform_tags", lambda: iter(["plat", "plat2"]))
brettcannon marked this conversation as resolved.
Show resolved Hide resolved
result = list(tags.compatible_tags((3, 1), "cp31"))
assert result == [
tags.Tag("py31", "none", "plat"),
tags.Tag("py31", "none", "plat2"),
tags.Tag("py3", "none", "plat"),
tags.Tag("py3", "none", "plat2"),
tags.Tag("py30", "none", "plat"),
tags.Tag("py30", "none", "plat2"),
tags.Tag("cp31", "none", "any"),
tags.Tag("py31", "none", "any"),
tags.Tag("py3", "none", "any"),
Expand Down