From: Andrew M. Kuchling Date: Wed, 20 Nov 2002 15:05:41 +0000 (+0000) Subject: Backport of rev1.57: X-Git-Tag: v2.2.3c1~221 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0e44fa9c299e1fee551fce8b4037ed3117a2458b;p=thirdparty%2FPython%2Fcpython.git Backport of rev1.57: 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.) --- diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index b648f24eb7e0..8a10fc5abc2b 100644 --- a/Lib/distutils/dist.py +++ b/Lib/distutils/dist.py @@ -12,6 +12,12 @@ __revision__ = "$Id$" import sys, os, string, re from types import * from copy import copy + +try: + import warnings +except: + warnings = None + from distutils.errors import * from distutils.fancy_getopt import FancyGetopt, translate_longopt from distutils.util import check_environ, strtobool, rfc822_escape @@ -204,8 +210,11 @@ class Distribution: elif hasattr(self, key): setattr(self, key, val) else: - raise DistutilsSetupError, \ - "invalid distribution option '%s'" % key + msg = "Unknown distribution option: %s" % repr(key) + if warnings is not None: + warnings.warn(msg) + else: + sys.stderr.write(msg + "\n") self.finalize_options()