mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
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:
parent
6a54c676e6
commit
dcaed6b2d9
6 changed files with 112 additions and 12 deletions
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue