From: Serhiy Storchaka Date: Sat, 21 Mar 2015 20:04:42 +0000 (+0200) Subject: Issue #23075: Whether __builtins__ is a module or a dict is undefined in X-Git-Tag: v2.7.10rc1~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9f696c9809cb1c9d6f4b8d2cd43dcf866825f4e3;p=thirdparty%2FPython%2Fcpython.git Issue #23075: Whether __builtins__ is a module or a dict is undefined in CPython. Use the reliably well defined `import __builtin__` instead. Patch by Alex Gaynor. --- diff --git a/Lib/test/_mock_backport.py b/Lib/test/_mock_backport.py index d3948310bbaf..f85becb06b57 100644 --- a/Lib/test/_mock_backport.py +++ b/Lib/test/_mock_backport.py @@ -24,6 +24,7 @@ __all__ = ( __version__ = '1.0' +import __builtin__ import inspect import pprint import sys @@ -32,7 +33,7 @@ from types import ModuleType from functools import wraps, partial -_builtins = {name for name in __builtins__ if not name.startswith('_')} +_builtins = {name for name in dir(__builtin__) if not name.startswith('_')} BaseExceptions = (BaseException,) if 'java' in sys.platform: