From 0e44fa9c299e1fee551fce8b4037ed3117a2458b Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Wed, 20 Nov 2002 15:05:41 +0000 Subject: [PATCH] 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.) --- Lib/distutils/dist.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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() -- 2.47.3