mirror of https://github.com/python/cpython
Merged revisions 73895 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r73895 | tarek.ziade | 2009-07-09 00:40:51 +0200 (Thu, 09 Jul 2009) | 1 line Sets the compiler attribute to keep the old behavior for third-party packages. ........
This commit is contained in:
parent
74c96ec399
commit
556934b385
|
@ -132,13 +132,17 @@ class build_ext(Command):
|
||||||
def _set_compiler(self, compiler):
|
def _set_compiler(self, compiler):
|
||||||
if not isinstance(compiler, str) and compiler is not None:
|
if not isinstance(compiler, str) and compiler is not None:
|
||||||
# we don't want to allow that anymore in the future
|
# we don't want to allow that anymore in the future
|
||||||
warn("'compiler' specify the compiler type in build_ext. "
|
warn("'compiler' specifies the compiler type in build_ext. "
|
||||||
"If you want to get the compiler object itself, "
|
"If you want to get the compiler object itself, "
|
||||||
"use 'compiler_obj'", PendingDeprecationWarning)
|
"use 'compiler_obj'", PendingDeprecationWarning)
|
||||||
|
|
||||||
self._compiler = compiler
|
self._compiler = compiler
|
||||||
|
|
||||||
def _get_compiler(self):
|
def _get_compiler(self):
|
||||||
|
if not isinstance(self._compiler, str) and self._compiler is not None:
|
||||||
|
# we don't want to allow that anymore in the future
|
||||||
|
warn("'compiler' specifies the compiler type in build_ext. "
|
||||||
|
"If you want to get the compiler object itself, "
|
||||||
|
"use 'compiler_obj'", PendingDeprecationWarning)
|
||||||
return self._compiler
|
return self._compiler
|
||||||
|
|
||||||
compiler = property(_get_compiler, _set_compiler)
|
compiler = property(_get_compiler, _set_compiler)
|
||||||
|
@ -341,10 +345,22 @@ class build_ext(Command):
|
||||||
|
|
||||||
# Setup the CCompiler object that we'll use to do all the
|
# Setup the CCompiler object that we'll use to do all the
|
||||||
# compiling and linking
|
# compiling and linking
|
||||||
self.compiler_obj = new_compiler(compiler=self.compiler,
|
|
||||||
|
# used to prevent the usage of an existing compiler for the
|
||||||
|
# compiler option when calling new_compiler()
|
||||||
|
# this will be removed in 3.3 and 2.8
|
||||||
|
if not isinstance(self._compiler, str):
|
||||||
|
self._compiler = None
|
||||||
|
|
||||||
|
self.compiler_obj = new_compiler(compiler=self._compiler,
|
||||||
verbose=self.verbose,
|
verbose=self.verbose,
|
||||||
dry_run=self.dry_run,
|
dry_run=self.dry_run,
|
||||||
force=self.force)
|
force=self.force)
|
||||||
|
|
||||||
|
# used to keep the compiler object reachable with
|
||||||
|
# "self.compiler". this will be removed in 3.3 and 2.8
|
||||||
|
self._compiler = self.compiler_obj
|
||||||
|
|
||||||
customize_compiler(self.compiler_obj)
|
customize_compiler(self.compiler_obj)
|
||||||
# If we are cross-compiling, init the compiler now (if we are not
|
# If we are cross-compiling, init the compiler now (if we are not
|
||||||
# cross-compiling, init would not hurt, but people may rely on
|
# cross-compiling, init would not hurt, but people may rely on
|
||||||
|
|
|
@ -402,12 +402,21 @@ class BuildExtTestCase(TempdirManager,
|
||||||
dist = Distribution()
|
dist = Distribution()
|
||||||
cmd = build_ext(dist)
|
cmd = build_ext(dist)
|
||||||
|
|
||||||
|
class MyCompiler(object):
|
||||||
|
def do_something(self):
|
||||||
|
pass
|
||||||
|
|
||||||
with check_warnings() as w:
|
with check_warnings() as w:
|
||||||
warnings.simplefilter("always")
|
warnings.simplefilter("always")
|
||||||
cmd.compiler = object()
|
cmd.compiler = MyCompiler()
|
||||||
self.assertEquals(len(w.warnings), 1)
|
self.assertEquals(len(w.warnings), 1)
|
||||||
cmd.compile = 'unix'
|
cmd.compile = 'unix'
|
||||||
self.assertEquals(len(w.warnings), 1)
|
self.assertEquals(len(w.warnings), 1)
|
||||||
|
cmd.compiler = MyCompiler()
|
||||||
|
cmd.compiler.do_something()
|
||||||
|
# two more warnings genereated by the get
|
||||||
|
# and the set
|
||||||
|
self.assertEquals(len(w.warnings), 3)
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
src = _get_source_filename()
|
src = _get_source_filename()
|
||||||
|
|
Loading…
Reference in New Issue