explain the nested import

This commit is contained in:
Jean-Paul Calderone 2021-01-11 14:04:20 -05:00
parent e6ee13d11b
commit a29b061f91

View File

@ -125,6 +125,13 @@ class GetArgvTests(SyncTestCase):
``get_argv`` returns a list representing the result of tokenizing the
"command line" argument string provided to Windows processes.
"""
# Python 2.7 doesn't have good options for launching a process with
# non-ASCII in its command line. So use this alternative that does a
# better job. Bury the import here because it only works on Windows.
from ._win_subprocess import (
Popen
)
working_path = FilePath(self.mktemp())
working_path.makedirs()
save_argv_path = working_path.child("script.py")
@ -144,11 +151,6 @@ class GetArgvTests(SyncTestCase):
f.write(json.dumps(get_argv()))
""".format(saved_argv_path.path)),
)
# Python 2.7 doesn't have good options for launching a process with
# non-ASCII in its command line.
from ._win_subprocess import (
Popen
)
argv = [executable.decode("utf-8"), save_argv_path.path] + argv
p = Popen(argv, stdin=PIPE, stdout=PIPE, stderr=PIPE)
p.stdin.close()