Skip to content

Commit

Permalink
Switch to explicit test for list/tuple
Browse files Browse the repository at this point in the history
As per discussion in pypa#1769 (comment)
  • Loading branch information
dhimmel committed Jul 3, 2019
1 parent ef002e7 commit d9035ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion changelog.d/1769.change.rst
@@ -1,3 +1,3 @@
The ``package_data`` and ``exclude_package_data`` arguments expect a dictionary whose values are a list of strings that represent paths/globs.
Check these arguments more thoroughly, such that an error is raised when providing a dictionary with a string value.
Also verify that dictionary values are multi-use iterables of strings (i.e. not single-use generators).
Also verify that dictionary values are lists (or tuples) of strings (i.e. not single-use generators or sets).
7 changes: 4 additions & 3 deletions setuptools/dist.py
Expand Up @@ -214,9 +214,10 @@ def check_importable(dist, attr, value):
def assert_string_list(dist, attr, value):
"""Verify that value is a string list"""
try:
# verify that value is not a single-use iterable
assert list(value) == list(value)
# verify that iterable contains strings
# verify that value is a list or tuple to exclude unordered
# or single-use iterables
assert isinstance(value, (list, tuple))
# verify that elements of value are strings
assert ''.join(value) != value
except (TypeError, ValueError, AttributeError, AssertionError):
raise DistutilsSetupError(
Expand Down

0 comments on commit d9035ef

Please sign in to comment.