Reference environment close to use

Variables in environment are only bound after calling
environment.use_stdlib() or environment.use_eventlet(). By binding the
variable at the top of a file like this it is assigned at import time
and so may be left referencing a None value. This means the value is
wrong when it is used later, even though it has since been bound
properly.

There are no additional tests for this as I'm really not sure how to do
it. It would involve testing a complicated series of module loading and
the problem will be negated when we remove eventlet.

Change-Id: Ic56a42c0f1a0fe4e8cc0b5512f00368a3ab8102c
Partial-Bug: #1521122
This commit is contained in:
Jamie Lennox 2015-11-30 21:09:35 +11:00
parent 933e118eee
commit 1981aeaeed
1 changed files with 1 additions and 2 deletions

View File

@ -37,8 +37,6 @@ from keystone import exception
from keystone.i18n import _, _LE
subprocess = environment.subprocess
LOG = log.getLogger(__name__)
CONF = cfg.CONF
@ -424,6 +422,7 @@ def _sign_assertion(assertion):
nspair={'saml': saml2.NAMESPACE,
'xmldsig': xmldsig.NAMESPACE}))
command_list.append(file_path)
subprocess = environment.subprocess
stdout = subprocess.check_output(command_list, # nosec : The contents
# of the command list are coming from
# a trusted source because the