Bug 1414842 - remove reliance on a CPython implementation detail in mozbuild; r=gps
authorAlex Gaynor <agaynor@mozilla.com>
Mon, 06 Nov 2017 10:36:15 -0500
changeset 693809 62aeebcc676e93dc56a97d44753f4e2f963d43c3
parent 693808 a0712da71d64d75d0db129abe481e93a5df13e70
child 693810 1ed5527d3f111432704e1df9cb87d5c65c87ee19
child 693830 c2fe4b3b1b930b3e7fdb84eae44cec165394f322
push id87924
push userbmo:mozilla@hocat.ca
push dateMon, 06 Nov 2017 22:10:10 +0000
reviewersgps
bugs1414842
milestone58.0a1
Bug 1414842 - remove reliance on a CPython implementation detail in mozbuild; r=gps MozReview-Commit-ID: SGrqK6NpEY
python/mozbuild/mozbuild/configure/__init__.py
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -1,14 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
+import __builtin__
 import inspect
 import logging
 import os
 import re
 import sys
 import types
 from collections import OrderedDict
 from contextlib import contextmanager
@@ -247,17 +248,17 @@ 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: __builtins__[b]
+        b: getattr(__builtin__, b)
         for b in ('None', 'False', 'True', 'int', 'bool', 'any', 'all', 'len',
                   'list', 'tuple', 'set', 'dict', 'isinstance', 'getattr',
                   'hasattr', 'enumerate', 'range', 'zip')
     }, __import__=forbidden_import, str=unicode)
 
     # Expose a limited set of functions from os.path
     OS = ReadOnlyNamespace(path=ReadOnlyNamespace(**{
         k: getattr(mozpath, k, getattr(os.path, k))