diff options
| author | Paul Ganssle <pganssle@users.noreply.github.com> | 2018-12-31 17:27:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-31 17:27:40 -0500 |
| commit | f5c04b1bb6c2f97305d7a92ce401194c5195197e (patch) | |
| tree | edeb927b51212a57e785b8f6a06b7f61b3599f48 /setuptools/config.py | |
| parent | 0c9624fd5ee5abe3fb0d1e3dfa68a9cbaf261aed (diff) | |
| parent | 3db95bcc3dcc72dbb47d7dfc987ae646b249addd (diff) | |
| download | external_python_setuptools-f5c04b1bb6c2f97305d7a92ce401194c5195197e.tar.gz external_python_setuptools-f5c04b1bb6c2f97305d7a92ce401194c5195197e.tar.bz2 external_python_setuptools-f5c04b1bb6c2f97305d7a92ce401194c5195197e.zip | |
Merge pull request #1559 from RajdeepRao/BUG-1551
Disallow files for license inputs
Diffstat (limited to 'setuptools/config.py')
| -rw-r--r-- | setuptools/config.py | 22 |
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, |
