changeset 25674:5d0847cd1587

demandimport: support importing builtins for Python 3 __builtin__ was renamed to builtins in Python 3. If importing __builtin__ fails, fall back to importing builtins in order to support Python 3.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 27 Jun 2015 17:31:06 -0700
parents fa1f04529775
children c76e8d14383a
files mercurial/demandimport.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/demandimport.py	Sat Jun 27 17:29:15 2015 -0700
+++ b/mercurial/demandimport.py	Sat Jun 27 17:31:06 2015 -0700
@@ -26,7 +26,12 @@
 
 import os, sys
 from contextlib import contextmanager
-import __builtin__ as builtins
+
+# __builtin__ in Python 2, builtins in Python 3.
+try:
+    import __builtin__ as builtins
+except ImportError:
+    import builtins
 
 _origimport = __import__