Commit 7447edbc authored by Ned Deily's avatar Ned Deily

Issue #21923: merge from 3.4

parents 3032ed7c 7bc5fb69
...@@ -179,7 +179,8 @@ def customize_compiler(compiler): ...@@ -179,7 +179,8 @@ def customize_compiler(compiler):
# version and build tools may not support the same set # version and build tools may not support the same set
# of CPU architectures for universal builds. # of CPU architectures for universal builds.
global _config_vars global _config_vars
if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): # Use get_config_var() to ensure _config_vars is initialized.
if not get_config_var('CUSTOMIZED_OSX_COMPILER'):
import _osx_support import _osx_support
_osx_support.customize_compiler(_config_vars) _osx_support.customize_compiler(_config_vars)
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
......
"""Tests for distutils.sysconfig.""" """Tests for distutils.sysconfig."""
import os import os
import shutil import shutil
import subprocess
import sys
import textwrap
import unittest import unittest
from distutils import sysconfig from distutils import sysconfig
...@@ -174,6 +177,25 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): ...@@ -174,6 +177,25 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase):
self.assertIsNotNone(vars['SO']) self.assertIsNotNone(vars['SO'])
self.assertEqual(vars['SO'], vars['EXT_SUFFIX']) self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
def test_customize_compiler_before_get_config_vars(self):
# Issue #21923: test that a Distribution compiler
# instance can be called without an explicit call to
# get_config_vars().
with open(TESTFN, 'w') as f:
f.writelines(textwrap.dedent('''\
from distutils.core import Distribution
config = Distribution().get_command_obj('config')
# try_compile may pass or it may fail if no compiler
# is found but it should not raise an exception.
rc = config.try_compile('int x;')
'''))
p = subprocess.Popen([str(sys.executable), TESTFN],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
outs, errs = p.communicate()
self.assertEqual(0, p.returncode, "Subprocess failed: " + outs)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -541,6 +541,8 @@ Library ...@@ -541,6 +541,8 @@ Library
- Issue #21801: Validate that __signature__ is None or an instance of Signature. - Issue #21801: Validate that __signature__ is None or an instance of Signature.
- Issue #21923: Prevent AttributeError in distutils.sysconfig.customize_compiler
due to possible uninitialized _config_vars.
Extension Modules Extension Modules
----------------- -----------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment