Skip to content

Commit

Permalink
pypa#257: save list in memory to avoid reusing exhausted iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
jdecroos-N committed Jan 21, 2020
1 parent e664cdd commit 9a25e2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packaging/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]))
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

0 comments on commit 9a25e2e

Please sign in to comment.