зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1748383 - In configure, make e.g. os.path.join mean the same thing whether importing os or not. r=firefox-build-system-reviewers,mhentges
Currently, using any of the functions defined in `ConfigureSandbox.OS.path` in a `@depends` function will have a different behavior if the function has an `@imports("os")` or not. In the former case, we get plain `os.path.$function`, while in the latter we get the function from `ConfigureSandbox.OS.path`, which handles path separators differently, which makes a significant difference on Windows. With this change, we now consistently use the versions from `ConfigureSandbox.OS.path`. Differential Revision: https://phabricator.services.mozilla.com/D135003
This commit is contained in:
Родитель
1fe66a3272
Коммит
de0df1009a
|
@ -1004,6 +1004,11 @@ class ConfigureSandbox(dict):
|
|||
# Special case os and os.environ so that os.environ is our copy of
|
||||
# the environment.
|
||||
wrapped_os["environ"] = self._environ
|
||||
# Also override some os.path functions with ours.
|
||||
wrapped_path = {}
|
||||
exec_("from os.path import *", {}, wrapped_path)
|
||||
wrapped_path.update(self.OS.path.__dict__)
|
||||
wrapped_os["path"] = ReadOnlyNamespace(**wrapped_path)
|
||||
return ReadOnlyNamespace(**wrapped_os)
|
||||
|
||||
@memoized_property
|
||||
|
|
|
@ -278,6 +278,12 @@ class TestConfigure(unittest.TestCase):
|
|||
|
||||
self.assertIs(sandbox["foo"](), sys)
|
||||
|
||||
# os.path after an import is a mix of vanilla os.path and sandbox os.path.
|
||||
os_path = {}
|
||||
exec_("from os.path import *", {}, os_path)
|
||||
os_path.update(sandbox.OS.path.__dict__)
|
||||
os_path = ReadOnlyNamespace(**os_path)
|
||||
|
||||
exec_(
|
||||
textwrap.dedent(
|
||||
"""
|
||||
|
@ -289,7 +295,7 @@ class TestConfigure(unittest.TestCase):
|
|||
sandbox,
|
||||
)
|
||||
|
||||
self.assertIs(sandbox["foo"](), os.path)
|
||||
self.assertEquals(sandbox["foo"](), os_path)
|
||||
|
||||
exec_(
|
||||
textwrap.dedent(
|
||||
|
@ -302,7 +308,7 @@ class TestConfigure(unittest.TestCase):
|
|||
sandbox,
|
||||
)
|
||||
|
||||
self.assertIs(sandbox["foo"](), os.path)
|
||||
self.assertEquals(sandbox["foo"](), os_path)
|
||||
|
||||
exec_(
|
||||
textwrap.dedent(
|
||||
|
|
Загрузка…
Ссылка в новой задаче