Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-31955: Fixed incorrect string type check - use isinstance(value, basestring)… #4316

Merged
merged 13 commits into from
Nov 8, 2017
2 changes: 1 addition & 1 deletion Lib/distutils/ccompiler.py
Original file line number Diff line number Diff line change
@@ -160,7 +160,7 @@ class (via the 'executables' class attribute), but most will have:
self.set_executable(key, args[key])

def set_executable(self, key, value):
if isinstance(value, str):
if isinstance(value, basestring):
setattr(self, key, split_quoted(value))
else:
setattr(self, key, value)
24 changes: 24 additions & 0 deletions Lib/distutils/tests/test_ccompiler.py
Original file line number Diff line number Diff line change
@@ -24,6 +24,30 @@ def library_option(self, lib):

class CCompilerTestCase(support.EnvironGuard, unittest.TestCase):

def test_set_executables(self):
class MyCCompiler(CCompiler):
executables = {'compiler': '', 'compiler_cxx': '', 'linker': ''}

compiler = MyCCompiler()

# set executable as list
compiler.set_executables(compiler=['env', 'OMPI_MPICC=clang', 'mpicc'])
self.assertEqual(compiler.compiler, ['env',
'OMPI_MPICC=clang',
'mpicc'])

# set executable as string
compiler.set_executables(compiler_cxx='env OMPI_MPICXX=clang++ mpicxx')
self.assertEqual(compiler.compiler_cxx, ['env',
'OMPI_MPICXX=clang++',
'mpicxx'])

# set executable as unicode string
compiler.set_executables(linker=u'env OMPI_MPICXX=clang++ mpiCC')
self.assertEqual(compiler.linker, [u'env',
u'OMPI_MPICXX=clang++',
u'mpiCC'])

def test_gen_lib_options(self):
compiler = FakeCompiler()
libdirs = ['lib1', 'lib2']
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix CCompiler.set_executable() of distutils to handle properly Unicode strings.