diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py index 43a8dc84393..f2ebe37dc90 100644 --- a/Lib/distutils/command/config.py +++ b/Lib/distutils/command/config.py @@ -12,7 +12,7 @@ this header file lives". __revision__ = "$Id$" import sys, os, string, re -from types import * + from distutils.core import Command from distutils.errors import DistutilsExecError from distutils.sysconfig import customize_compiler @@ -68,19 +68,18 @@ class config(Command): def finalize_options(self): if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or [] - elif type(self.include_dirs) is StringType: - self.include_dirs = string.split(self.include_dirs, os.pathsep) + elif isinstance(self.include_dirs, str): + self.include_dirs = self.include_dirs.split(os.pathsep) if self.libraries is None: self.libraries = [] - elif type(self.libraries) is StringType: + elif isinstance(self.libraries, str): self.libraries = [self.libraries] if self.library_dirs is None: self.library_dirs = [] - elif type(self.library_dirs) is StringType: - self.library_dirs = string.split(self.library_dirs, os.pathsep) - + elif isinstance(self.library_dirs, str): + self.library_dirs = self.library_dirs.split(os.pathsep) def run (self): pass diff --git a/Lib/distutils/tests/test_config_cmd.py b/Lib/distutils/tests/test_config_cmd.py index af16d4c8219..45d480ba5aa 100644 --- a/Lib/distutils/tests/test_config_cmd.py +++ b/Lib/distutils/tests/test_config_cmd.py @@ -46,6 +46,21 @@ class ConfigTestCase(support.LoggingSilencer, match = cmd.search_cpp(pattern='command', body='// xxx') self.assertEquals(match, 1) + def test_finalize_options(self): + # finalize_options does a bit of transformation + # on options + pkg_dir, dist = self.create_dist() + cmd = config(dist) + cmd.include_dirs = 'one%stwo' % os.pathsep + cmd.libraries = 'one' + cmd.library_dirs = 'three%sfour' % os.pathsep + cmd.ensure_finalized() + + self.assertEquals(cmd.include_dirs, ['one', 'two']) + self.assertEquals(cmd.libraries, ['one']) + self.assertEquals(cmd.library_dirs, ['three', 'four']) + + def test_suite(): return unittest.makeSuite(ConfigTestCase)