aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/config.py
diff options
context:
space:
mode:
authorrajdeep <rajdeeprrao94@gmail.com>2018-10-28 15:38:18 -0400
committerPaul Ganssle <paul@ganssle.io>2018-12-29 11:14:12 -0500
commit8f00d60d623fdc1b8614c5e454edebf8cec504b8 (patch)
tree98c8af958eff765aece3a915b4ee0c54d4c9ed68 /setuptools/config.py
parent17ad2b72ed29c91fd32e939abf3625314fe7c4ed (diff)
downloadexternal_python_setuptools-8f00d60d623fdc1b8614c5e454edebf8cec504b8.tar.gz
external_python_setuptools-8f00d60d623fdc1b8614c5e454edebf8cec504b8.tar.bz2
external_python_setuptools-8f00d60d623fdc1b8614c5e454edebf8cec504b8.zip
Disallow files for license inputs
The ability to handle files was originally added and documented based on a misunderstanding of what the `license` field should include. The field should be the name of the license, not the full text. It is likely that anyone actually using this was outputing malformed PKG-INFO files, because most license files contain newlines. See GH issue #1551
Diffstat (limited to 'setuptools/config.py')
-rw-r--r--setuptools/config.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/setuptools/config.py b/setuptools/config.py
index d1ac6734..3a6da20f 100644
--- a/setuptools/config.py
+++ b/setuptools/config.py
@@ -247,6 +247,24 @@ class ConfigHandler:
return value in ('1', 'true', 'yes')
@classmethod
+ def _exclude_files_parser(cls, key):
+ """Returns a parser function to make sure field inputs
+ are not files.
+
+ Parses a value after getting the key so error messages are
+ more informative.
+
+ :param key:
+ :rtype: callable
+ """
+ def parser(value):
+ exclude_directive = 'file:'
+ if value.startswith(exclude_directive):
+ raise ValueError('Only strings are accepted for the {0} field, files are not accepted'.format(key))
+ return value
+ return parser
+
+ @classmethod
def _parse_file(cls, value):
"""Represents value as a string, allowing including text
from nearest files using `file:` directive.
@@ -255,7 +273,6 @@ class ConfigHandler:
directory with setup.py.
Examples:
- file: LICENSE
file: README.rst, CHANGELOG.md, src/file.txt
:param str value:
@@ -449,6 +466,7 @@ class ConfigMetadataHandler(ConfigHandler):
parse_list = self._parse_list
parse_file = self._parse_file
parse_dict = self._parse_dict
+ exclude_files_parser = self._exclude_files_parser
return {
'platforms': parse_list,
@@ -460,7 +478,7 @@ class ConfigMetadataHandler(ConfigHandler):
DeprecationWarning),
'obsoletes': parse_list,
'classifiers': self._get_parser_compound(parse_file, parse_list),
- 'license': parse_file,
+ 'license': exclude_files_parser('license'),
'description': parse_file,
'long_description': parse_file,
'version': self._parse_version,