summaryrefslogtreecommitdiff
path: root/Lib/distutils
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2015-08-07 19:48:43 -0700
committerSteve Dower <steve.dower@microsoft.com>2015-08-07 19:48:43 -0700
commit8d12a7fb92da0c4e249f8e7dc4fdb7e7e71d60ed (patch)
treec372136a139f59eb9760183d01f8cde267c2fd7a /Lib/distutils
parent02591ac927cdaade794a296cea18f47aedc7f1f2 (diff)
parente04e184d106ad639fe46c41b99b872ea5f3e9b6c (diff)
downloadcpython-8d12a7fb92da0c4e249f8e7dc4fdb7e7e71d60ed.tar.gz
Issue #4214: Remove ineffectual /pdb:none option from msvc9compiler.py
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/core.py5
-rw-r--r--Lib/distutils/tests/test_core.py30
2 files changed, 32 insertions, 3 deletions
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py
index f05b34b295..d603d4a45a 100644
--- a/Lib/distutils/core.py
+++ b/Lib/distutils/core.py
@@ -204,16 +204,15 @@ def run_setup (script_name, script_args=None, stop_after="run"):
global _setup_stop_after, _setup_distribution
_setup_stop_after = stop_after
- save_argv = sys.argv
+ save_argv = sys.argv.copy()
g = {'__file__': script_name}
- l = {}
try:
try:
sys.argv[0] = script_name
if script_args is not None:
sys.argv[1:] = script_args
with open(script_name, 'rb') as f:
- exec(f.read(), g, l)
+ exec(f.read(), g)
finally:
sys.argv = save_argv
_setup_stop_after = None
diff --git a/Lib/distutils/tests/test_core.py b/Lib/distutils/tests/test_core.py
index 41321f7db4..57856f19b6 100644
--- a/Lib/distutils/tests/test_core.py
+++ b/Lib/distutils/tests/test_core.py
@@ -28,6 +28,21 @@ from distutils.core import setup
setup()
"""
+setup_does_nothing = """\
+from distutils.core import setup
+setup()
+"""
+
+
+setup_defines_subclass = """\
+from distutils.core import setup
+from distutils.command.install import install as _install
+
+class install(_install):
+ sub_commands = _install.sub_commands + ['cmd']
+
+setup(cmdclass={'install': install})
+"""
class CoreTestCase(support.EnvironGuard, unittest.TestCase):
@@ -65,6 +80,21 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
distutils.core.run_setup(
self.write_setup(setup_using___file__))
+ def test_run_setup_preserves_sys_argv(self):
+ # Make sure run_setup does not clobber sys.argv
+ argv_copy = sys.argv.copy()
+ distutils.core.run_setup(
+ self.write_setup(setup_does_nothing))
+ self.assertEqual(sys.argv, argv_copy)
+
+ def test_run_setup_defines_subclass(self):
+ # Make sure the script can use __file__; if that's missing, the test
+ # setup.py script will raise NameError.
+ dist = distutils.core.run_setup(
+ self.write_setup(setup_defines_subclass))
+ install = dist.get_command_obj('install')
+ self.assertIn('cmd', install.sub_commands)
+
def test_run_setup_uses_current_dir(self):
# This tests that the setup script is run with the current directory
# as its own current directory; this was temporarily broken by a