mirror of
https://github.com/python/cpython.git
synced 2025-11-09 01:51:26 +00:00
Cleaned up/simplified error-handling:
- DistutilsOptionError is now documented as it's actually used, ie.
to indicate bogus option values (usually user options, eg. from
the command-line)
- added DistutilsSetupError to indicate errors that definitely arise
in the setup script
- got rid of DistutilsValueError, and changed all usage of it to
either DistutilsSetupError or ValueError as appropriate
- simplified a bunch of option get/set methods in Command and
Distribution classes -- just pass on AttributeError most of
the time, rather than turning it into something else
This commit is contained in:
parent
4a3dd2dcc2
commit
02a1a2b077
7 changed files with 52 additions and 79 deletions
|
|
@ -205,26 +205,26 @@ def check_extensions_list (self, extensions):
|
|||
"""Ensure that the list of extensions (presumably provided as a
|
||||
command option 'extensions') is valid, i.e. it is a list of
|
||||
2-tuples, where the tuples are (extension_name, build_info_dict).
|
||||
Raise DistutilsValueError if the structure is invalid anywhere;
|
||||
Raise DistutilsSetupError if the structure is invalid anywhere;
|
||||
just returns otherwise."""
|
||||
|
||||
if type (extensions) is not ListType:
|
||||
raise DistutilsValueError, \
|
||||
raise DistutilsSetupError, \
|
||||
"'ext_modules' option must be a list of tuples"
|
||||
|
||||
for ext in extensions:
|
||||
if type (ext) is not TupleType and len (ext) != 2:
|
||||
raise DistutilsValueError, \
|
||||
raise DistutilsSetupError, \
|
||||
"each element of 'ext_modules' option must be a 2-tuple"
|
||||
|
||||
if not (type (ext[0]) is StringType and
|
||||
extension_name_re.match (ext[0])):
|
||||
raise DistutilsValueError, \
|
||||
raise DistutilsSetupError, \
|
||||
"first element of each tuple in 'ext_modules' " + \
|
||||
"must be the extension name (a string)"
|
||||
|
||||
if type (ext[1]) is not DictionaryType:
|
||||
raise DistutilsValueError, \
|
||||
raise DistutilsSetupError, \
|
||||
"second element of each tuple in 'ext_modules' " + \
|
||||
"must be a dictionary (build info)"
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ def build_extensions (self):
|
|||
for (extension_name, build_info) in self.extensions:
|
||||
sources = build_info.get ('sources')
|
||||
if sources is None or type (sources) not in (ListType, TupleType):
|
||||
raise DistutilsValueError, \
|
||||
raise DistutilsSetupError, \
|
||||
("in 'ext_modules' option (extension '%s'), " +
|
||||
"'sources' must be present and must be " +
|
||||
"a list of source filenames") % extension_name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue