summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/dist.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-04-15 22:15:07 (GMT)
committerGreg Ward <gward@python.net>2000-04-15 22:15:07 (GMT)
commit02a1a2b077e969e5fef8504cece5852bf641552d (patch)
tree4adea05076d4dab820180e6c9290ae9b1d7b28a4 /Lib/distutils/dist.py
parent4a3dd2dcc2fae12b6736822731848c557b80d0e3 (diff)
downloadcpython-02a1a2b077e969e5fef8504cece5852bf641552d.zip
cpython-02a1a2b077e969e5fef8504cece5852bf641552d.tar.gz
cpython-02a1a2b077e969e5fef8504cece5852bf641552d.tar.bz2
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
Diffstat (limited to 'Lib/distutils/dist.py')
-rw-r--r--Lib/distutils/dist.py36
1 files changed, 9 insertions, 27 deletions
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index cb18031..408b9f5 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -152,7 +152,7 @@ class Distribution:
if hasattr (self, key):
setattr (self, key, val)
else:
- raise DistutilsOptionError, \
+ raise DistutilsSetupError, \
"invalid distribution option '%s'" % key
# __init__ ()
@@ -447,27 +447,18 @@ class Distribution:
def get_option (self, option):
"""Return the value of a distribution option. Raise
- DistutilsOptionError if 'option' is not known."""
-
- try:
- return getattr (self, opt)
- except AttributeError:
- raise DistutilsOptionError, \
- "unknown distribution option %s" % option
+ AttributeError if 'option' is not known."""
+ return getattr (self, opt)
def get_options (self, *options):
"""Return (as a tuple) the values of several distribution
- options. Raise DistutilsOptionError if any element of
+ options. Raise AttributeError if any element of
'options' is not known."""
values = []
- try:
- for opt in options:
- values.append (getattr (self, opt))
- except AttributeError, name:
- raise DistutilsOptionError, \
- "unknown distribution option %s" % name
+ for opt in options:
+ values.append (getattr (self, opt))
return tuple (values)
@@ -498,17 +489,12 @@ class Distribution:
def get_command_option (self, command, option):
"""Create a command object for 'command' if necessary, ensure that
its option values are all set to their final values, and return
- the value of its 'option' option. Raise DistutilsOptionError if
+ the value of its 'option' option. Raise AttributeError if
'option' is not known for that 'command'."""
cmd_obj = self.find_command_obj (command)
cmd_obj.ensure_ready ()
return cmd_obj.get_option (option)
- try:
- return getattr (cmd_obj, option)
- except AttributeError:
- raise DistutilsOptionError, \
- "command %s: no such option %s" % (command, option)
def get_command_options (self, command, *options):
@@ -521,12 +507,8 @@ class Distribution:
cmd_obj = self.find_command_obj (command)
cmd_obj.ensure_ready ()
values = []
- try:
- for opt in options:
- values.append (getattr (cmd_obj, option))
- except AttributeError, name:
- raise DistutilsOptionError, \
- "command %s: no such option %s" % (command, name)
+ for opt in options:
+ values.append (getattr (cmd_obj, option))
return tuple (values)