mirror of
https://github.com/python/cpython.git
synced 2025-10-24 07:26:11 +00:00
Make the Distribution() constructor forgiving of unknown keyword
arguments, triggering a warning instead of raising an exception. (In 1.5.2/2.0, it will print to stderr.) Bugfix candidate for all previous versions. This changes behaviour, but the old behaviour wasn't very useful. If Distutils version X+1 adds a new keyword argument, using the new keyword means your setup.py file won't work with Distutils version X any more.
This commit is contained in:
parent
699799e6f3
commit
ff4ad9a1ce
1 changed files with 11 additions and 2 deletions
|
|
@ -12,6 +12,12 @@ __revision__ = "$Id$"
|
||||||
import sys, os, string, re
|
import sys, os, string, re
|
||||||
from types import *
|
from types import *
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
|
try:
|
||||||
|
import warnings
|
||||||
|
except:
|
||||||
|
warnings = None
|
||||||
|
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
from distutils.fancy_getopt import FancyGetopt, translate_longopt
|
from distutils.fancy_getopt import FancyGetopt, translate_longopt
|
||||||
from distutils.util import check_environ, strtobool, rfc822_escape
|
from distutils.util import check_environ, strtobool, rfc822_escape
|
||||||
|
|
@ -206,8 +212,11 @@ class Distribution:
|
||||||
elif hasattr(self, key):
|
elif hasattr(self, key):
|
||||||
setattr(self, key, val)
|
setattr(self, key, val)
|
||||||
else:
|
else:
|
||||||
raise DistutilsSetupError, \
|
msg = "Unknown distribution option: %s" % repr(key)
|
||||||
"invalid distribution option '%s'" % key
|
if warnings is not None:
|
||||||
|
warnings.warn(msg)
|
||||||
|
else:
|
||||||
|
sys.stderr.write(msg + "\n")
|
||||||
|
|
||||||
self.finalize_options()
|
self.finalize_options()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue