[Python-checkins] python/dist/src/Lib/distutils extension.py,1.13,1.14

akuchling@users.sourceforge.net akuchling@users.sourceforge.net
Wed, 13 Nov 2002 12:54:24 -0800


Update of /cvsroot/python/python/dist/src/Lib/distutils
In directory usw-pr-cvs1:/tmp/cvs-serv26844

Modified Files:
	extension.py 
Log Message:
Allow unknown keyword arguments to the Extension class, and warn about them.


Index: extension.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/extension.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** extension.py	5 Nov 2002 16:11:56 -0000	1.13
--- extension.py	13 Nov 2002 20:54:21 -0000	1.14
***************
*** 11,14 ****
--- 11,18 ----
  from types import *
  
+ try:
+     import warnings
+ except ImportError:
+     warnings = None
  
  # This class is really only used by the "build_ext" command, so it might
***************
*** 94,99 ****
                    depends=None,
                    language=None,
                   ):
- 
          assert type(name) is StringType, "'name' must be a string"
          assert (type(sources) is ListType and
--- 98,103 ----
                    depends=None,
                    language=None,
+                   **kw                      # To catch unknown keywords
                   ):
          assert type(name) is StringType, "'name' must be a string"
          assert (type(sources) is ListType and
***************
*** 116,119 ****
--- 120,132 ----
          self.language = language
  
+         # 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