From e8b80169f3c23244b1b79a1c2134bd15b105850b Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Wed, 20 Nov 2002 16:14:31 +0000 Subject: [PATCH] Backport rev. 1.14: Allow unknown keyword arguments to the Extension class, and warn about them. --- Lib/distutils/extension.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Lib/distutils/extension.py b/Lib/distutils/extension.py index a31ccbce8da5..46323b7550a0 100644 --- a/Lib/distutils/extension.py +++ b/Lib/distutils/extension.py @@ -7,9 +7,13 @@ modules in setup scripts.""" __revision__ = "$Id$" -import os, string +import os, string, sys from types import * +try: + import warnings +except ImportError: + warnings = None # This class is really only used by the "build_ext" command, so it might # make sense to put it in distutils.command.build_ext. However, that @@ -86,6 +90,7 @@ class Extension: extra_compile_args=None, extra_link_args=None, export_symbols=None, + **kw # To catch unknown keywords ): assert type(name) is StringType, "'name' must be a string" @@ -106,6 +111,15 @@ class Extension: self.extra_link_args = extra_link_args or [] self.export_symbols = export_symbols or [] + # If there are unknown keyword options, warn about them + if len(kw): + L = kw.keys() ; L.sort() + L = map(repr, L) + msg = "Unknown Extension options: " + string.join(L, ', ') + if warnings is not None: + warnings.warn(msg) + else: + sys.stderr.write(msg + '\n') # class Extension -- 2.47.3