[reader] use six.moves to get at __builtin__ or builtins module

Related to #267910.

authorJulien Cristau <julien.cristau@logilab.fr>
changeseta54af46409ce
branchdefault
phasepublic
hiddenno
parent revision#88c2c8b7373d [constraints] deal with py3k's string types
child revision#cfc4e2fb9167 [schema] deal with py3k's string types
files modified by this revision
reader.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1413453167 -7200
# Thu Oct 16 11:52:47 2014 +0200
# Node ID a54af46409ce25813261cf51b842cf4d8b6640c4
# Parent 88c2c8b7373dcdc7d1db606255507951fa7cb6d8
[reader] use six.moves to get at __builtin__ or builtins module

Related to #267910.

diff --git a/reader.py b/reader.py
@@ -241,19 +241,19 @@
1              assert abspath(module.__file__).startswith(abspath(filepath)), (
2                  modname, filepath, module.__file__)
3          else:
4              # XXX until bw compat is gone, put context into builtins to allow proper
5              # control of deprecation warning
6 -            import __builtin__
7 +            from six.moves import builtins
8              fglobals = {} # self.context.copy()
9              # wrap callable that should be imported
10              for key, val in self.context.items():
11                  if key in BASE_TYPES or key == 'RichString' or key in CONSTRAINTS or \
12                         key in ('SubjectRelation', 'ObjectRelation'):
13                      val = obsolete(val)
14 -                setattr(__builtin__, key, val)
15 -            __builtin__.import_erschema = self.import_erschema
16 +                setattr(builtins, key, val)
17 +            builtins.import_erschema = self.import_erschema
18              fglobals['__file__'] = filepath
19              fglobals['__name__'] = modname
20              package = '.'.join(modname.split('.')[:-1])
21              if package and not package in sys.modules:
22                  __import__(package)