summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/extension.py
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-06-03 11:12:08 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2009-06-03 11:12:08 (GMT)
commitfe327b97d2d797158e71d24a6918c8f57f3d65fd (patch)
tree208afa9ca8dd512ff33c83bc64c605edbdeada46 /Lib/distutils/extension.py
parentc6709978acf6b580af8ad2dfa3ff7b0d3d919f19 (diff)
downloadcpython-fe327b97d2d797158e71d24a6918c8f57f3d65fd.zip
cpython-fe327b97d2d797158e71d24a6918c8f57f3d65fd.tar.gz
cpython-fe327b97d2d797158e71d24a6918c8f57f3d65fd.tar.bz2
more cleanup and test coverage for distutils.extension
Diffstat (limited to 'Lib/distutils/extension.py')
-rw-r--r--Lib/distutils/extension.py33
1 files changed, 12 insertions, 21 deletions
diff --git a/Lib/distutils/extension.py b/Lib/distutils/extension.py
index 4d72c40..98b841f 100644
--- a/Lib/distutils/extension.py
+++ b/Lib/distutils/extension.py
@@ -5,13 +5,9 @@ modules in setup scripts."""
__revision__ = "$Id$"
-import os, string, sys
-from types import *
-
-try:
- import warnings
-except ImportError:
- warnings = None
+import os
+import sys
+import warnings
# 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
@@ -107,9 +103,9 @@ class Extension:
optional=None,
**kw # To catch unknown keywords
):
- assert type(name) is StringType, "'name' must be a string"
- assert (type(sources) is ListType and
- map(type, sources) == [StringType]*len(sources)), \
+ assert isinstance(name, str)
+ assert (isinstance(sources, list) and
+ all(isinstance(v, str) for v in sources)), \
"'sources' must be a list of strings"
self.name = name
@@ -130,16 +126,11 @@ class Extension:
self.optional = optional
# 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
-
+ if len(kw) > 0:
+ options = [repr(option) for option in kw]
+ options = ', '.join(sorted(options))
+ msg = "Unknown Extension options: %s" % options
+ warnings.warn(msg)
def read_setup_file(filename):
"""Reads a Setup file and returns Extension instances."""
@@ -200,7 +191,7 @@ def read_setup_file(filename):
elif switch == "-I":
ext.include_dirs.append(value)
elif switch == "-D":
- equals = string.find(value, "=")
+ equals = value.find("=")
if equals == -1: # bare "-DFOO" -- no value
ext.define_macros.append((value, None))
else: # "-DFOO=blah"