bpo-19610: setup() now raises TypeError for invalid types (GH-4519)

The Distribution class now explicitly raises an
exception when 'classifiers', 'keywords' and
'platforms' fields are not specified as a list.
This commit is contained in:
Berker Peksag 2017-11-23 21:34:20 +03:00 committed by GitHub
parent 6a54c676e6
commit dcaed6b2d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 112 additions and 12 deletions

View file

@ -1188,12 +1188,38 @@ class DistributionMetadata:
def get_keywords(self):
return self.keywords or []
def set_keywords(self, value):
# If 'keywords' is a string, it will be converted to a list
# by Distribution.finalize_options(). To maintain backwards
# compatibility, do not raise an exception if 'keywords' is
# a string.
if not isinstance(value, (list, str)):
msg = "'keywords' should be a 'list', not %r"
raise TypeError(msg % type(value).__name__)
self.keywords = value
def get_platforms(self):
return self.platforms or ["UNKNOWN"]
def set_platforms(self, value):
# If 'platforms' is a string, it will be converted to a list
# by Distribution.finalize_options(). To maintain backwards
# compatibility, do not raise an exception if 'platforms' is
# a string.
if not isinstance(value, (list, str)):
msg = "'platforms' should be a 'list', not %r"
raise TypeError(msg % type(value).__name__)
self.platforms = value
def get_classifiers(self):
return self.classifiers or []
def set_classifiers(self, value):
if not isinstance(value, list):
msg = "'classifiers' should be a 'list', not %r"
raise TypeError(msg % type(value).__name__)
self.classifiers = value
def get_download_url(self):
return self.download_url or "UNKNOWN"