Bug 1547730 - Make more of configure/__init__ work in py3 r=#build
☠☠ backed out by ee4b88439111 ☠ ☠
authorJustin Wood <Callek@gmail.com>
Tue, 16 Apr 2019 12:02:18 -0400
changeset 474155 48f2c4980ad0f2cccf92d9a45c0885db3f1f7b45
parent 474154 cef492de6a7f54986925e2e2f56cbdcdad04a916
child 474156 27ff9602d80a13414d81422eaa02d01d60475a4e
push id36023
push userncsoregi@mozilla.com
push dateThu, 16 May 2019 21:56:43 +0000
treeherdermozilla-central@786f094a30ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1547730
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1547730 - Make more of configure/__init__ work in py3 r=#build (adds __build_class__ to the builtin sandbox and allow CombinedDependsFunction to be hashed) Differential Revision: https://phabricator.services.mozilla.com/D28114
python/mozbuild/mozbuild/configure/__init__.py
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -284,20 +284,22 @@ class ConfigureSandbox(dict):
         sandbox = ConfigureSandbox(config)
         sandbox.run(path)
         do_stuff(config)
     """
 
     # The default set of builtins. We expose unicode as str to make sandboxed
     # files more python3-ready.
     BUILTINS = ReadOnlyDict({
-        b: getattr(__builtin__, b)
+        b: getattr(__builtin__, b, None)
         for b in ('None', 'False', 'True', 'int', 'bool', 'any', 'all', 'len',
                   'list', 'tuple', 'set', 'dict', 'isinstance', 'getattr',
-                  'hasattr', 'enumerate', 'range', 'zip', 'AssertionError')
+                  'hasattr', 'enumerate', 'range', 'zip', 'AssertionError',
+                  '__build_class__',  # will be None on py2
+                  )
     }, __import__=forbidden_import, str=six.text_type)
 
     # Expose a limited set of functions from os.path
     OS = ReadOnlyNamespace(path=ReadOnlyNamespace(**{
         k: getattr(mozpath, k, getattr(os.path, k))
         for k in ('abspath', 'basename', 'dirname', 'isabs', 'join',
                   'normcase', 'normpath', 'realpath', 'relpath')
     }))
@@ -369,17 +371,17 @@ class ConfigureSandbox(dict):
 
         def wrapped_log_method(logger, key):
             method = getattr(logger, key)
             if not encoding:
                 return method
 
             def wrapped(*args, **kwargs):
                 out_args = [
-                    arg.decode(encoding) if isinstance(arg, str) else arg
+                    arg.decode(encoding) if isinstance(arg, six.binary_type) else arg
                     for arg in args
                 ]
                 return method(*out_args, **kwargs)
             return wrapped
 
         log_namespace = {
             k: wrapped_log_method(logger, k)
             for k in ('debug', 'info', 'warning', 'error')