Mercurial > ~astiob > upreckon > hgweb
diff 2.00/compat.py @ 27:dc4be35d17e0
Bug fixes
Bug fix: compat.py now works in Python 3 (module __builtin__ was renamed builtins).
Bug fix: random spaces in the indentation of testcases.py have been removed.
Bug fix: false dummy{in,out}name's are now again replaced with the values of testcase{in,out}name.
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Fri, 15 Oct 2010 22:17:31 +0000 |
parents | b500e117080e |
children | fe1463e7e24d |
line wrap: on
line diff
--- a/2.00/compat.py Thu Sep 23 23:50:45 2010 +0000 +++ b/2.00/compat.py Fri Oct 15 22:17:31 2010 +0000 @@ -25,7 +25,10 @@ # with Python 2 and not usable conditionally via exec() and such # because it is a detail of the syntax of the class statement itself. -import __builtin__ +try: + import builtins +except ImportError: + import __builtin__ as builtins __all__ = ('say', 'basestring', 'range', 'map', 'zip', 'filter', 'items', 'keys', 'values', 'zip_longest', 'callable', @@ -40,7 +43,7 @@ # An alternative is exec('from __future__ import print_function; say = print'); # if problems arise with the current line, one should try replacing it # with this one with the future import before abandoning the idea altogether - say = __builtins__['print'] + say = getattr(builtins, 'print') except Exception: # Python 2.5 import sys @@ -144,12 +147,12 @@ def __enter__(self): g = globals() for name in __all__: - if hasattr(__builtin__, name): - self.originals[name] = getattr(__builtin__, name) - setattr(__builtin__, name, g[name]) + if hasattr(builtins, name): + self.originals[name] = getattr(builtins, name) + setattr(builtins, name, g[name]) def __exit__(self, exc_type, exc_val, exc_tb): for name in self.originals: - setattr(__builtin__, name, self.originals[name]) + setattr(builtins, name, self.originals[name]) # Support simple testconf.py's written for test.py 1.x -__builtin__.xrange = range \ No newline at end of file +builtins.xrange = range \ No newline at end of file