Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r48889:3e341a64f85c Date: 2011-11-07 14:25 -0800 http://bitbucket.org/pypy/pypy/changeset/3e341a64f85c/
Log: 2to3 diff --git a/pypy/conftest.py b/pypy/conftest.py --- a/pypy/conftest.py +++ b/pypy/conftest.py @@ -72,7 +72,7 @@ """ try: config = make_config(option, objspace=name, **kwds) - except ConflictConfigError, e: + except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped py.test.skip(str(e)) @@ -96,7 +96,7 @@ config = make_config(option) try: space = make_objspace(config) - except OperationError, e: + except OperationError as e: check_keyboard_interrupt(e) if option.verbose: import traceback @@ -118,7 +118,7 @@ def __init__(self, **kwds): import sys info = getattr(sys, 'pypy_translation_info', None) - for key, value in kwds.iteritems(): + for key, value in kwds.items(): if key == 'usemodules': if info is not None: for modname in value: @@ -148,7 +148,7 @@ assert body.startswith('(') src = py.code.Source("def anonymous" + body) d = {} - exec src.compile() in d + exec(src.compile(), d) return d['anonymous'](*args) def wrap(self, obj): @@ -210,9 +210,9 @@ source = py.code.Source(target)[1:].deindent() res, stdout, stderr = runsubprocess.run_subprocess( python, ["-c", helpers + str(source)]) - print source - print >> sys.stdout, stdout - print >> sys.stderr, stderr + print(source) + print(stdout, file=sys.stdout) + print(stderr, file=sys.stderr) if res > 0: raise AssertionError("Subprocess failed") @@ -225,7 +225,7 @@ try: if e.w_type.name == 'KeyboardInterrupt': tb = sys.exc_info()[2] - raise OpErrKeyboardInterrupt, OpErrKeyboardInterrupt(), tb + raise OpErrKeyboardInterrupt().with_traceback(tb) except AttributeError: pass @@ -240,7 +240,7 @@ apparently earlier on "raises" was already added to module's globals. """ - import __builtin__ + import builtins for helper in helpers: if not hasattr(__builtin__, helper): setattr(__builtin__, helper, getattr(py.test, helper)) @@ -304,10 +304,10 @@ elif hasattr(obj, 'func_code') and self.funcnamefilter(name): if name.startswith('app_test_'): - assert not obj.func_code.co_flags & 32, \ + assert not obj.__code__.co_flags & 32, \ "generator app level functions? you must be joking" return AppTestFunction(name, parent=self) - elif obj.func_code.co_flags & 32: # generator function + elif obj.__code__.co_flags & 32: # generator function return pytest.Generator(name, parent=self) else: return IntTestFunction(name, parent=self) @@ -321,7 +321,7 @@ "(btw, i would need options: %s)" % (ropts,)) for opt in ropts: - if not options.has_key(opt) or options[opt] != ropts[opt]: + if opt not in options or options[opt] != ropts[opt]: break else: return @@ -387,10 +387,10 @@ def runtest(self): try: super(IntTestFunction, self).runtest() - except OperationError, e: + except OperationError as e: check_keyboard_interrupt(e) raise - except Exception, e: + except Exception as e: cls = e.__class__ while cls is not Exception: if cls.__name__ == 'DistutilsPlatformError': @@ -411,13 +411,13 @@ def execute_appex(self, space, target, *args): try: target(*args) - except OperationError, e: + except OperationError as e: tb = sys.exc_info()[2] if e.match(space, space.w_KeyboardInterrupt): - raise OpErrKeyboardInterrupt, OpErrKeyboardInterrupt(), tb + raise OpErrKeyboardInterrupt().with_traceback(tb) appexcinfo = appsupport.AppExceptionInfo(space, e) if appexcinfo.traceback: - raise AppError, AppError(appexcinfo), tb + raise AppError(appexcinfo).with_traceback(tb) raise def runtest(self): @@ -429,7 +429,7 @@ space = gettestobjspace() filename = self._getdynfilename(target) func = app2interp_temp(target, filename=filename) - print "executing", func + print("executing", func) self.execute_appex(space, func, space) def repr_failure(self, excinfo): @@ -438,7 +438,7 @@ return super(AppTestFunction, self).repr_failure(excinfo) def _getdynfilename(self, func): - code = getattr(func, 'im_func', func).func_code + code = getattr(func, 'im_func', func).__code__ return "[%s:%s]" % (code.co_filename, code.co_firstlineno) class AppTestMethod(AppTestFunction): @@ -471,9 +471,9 @@ if self.config.option.appdirect: return run_with_python(self.config.option.appdirect, target) return target() - space = target.im_self.space + space = target.__self__.space filename = self._getdynfilename(target) - func = app2interp_temp(target.im_func, filename=filename) + func = app2interp_temp(target.__func__, filename=filename) w_instance = self.parent.w_instance self.execute_appex(space, func, space, w_instance) diff --git a/pypy/module/__builtin__/test/autopath.py b/pypy/module/__builtin__/test/autopath.py --- a/pypy/module/__builtin__/test/autopath.py +++ b/pypy/module/__builtin__/test/autopath.py @@ -66,7 +66,7 @@ sys.path.insert(0, head) munged = {} - for name, mod in sys.modules.items(): + for name, mod in list(sys.modules.items()): if '.' in name: continue fn = getattr(mod, '__file__', None) @@ -84,7 +84,7 @@ if modpath not in sys.modules: munged[modpath] = mod - for name, mod in munged.iteritems(): + for name, mod in munged.items(): if name not in sys.modules: sys.modules[name] = mod if '.' in name: @@ -111,9 +111,9 @@ f = open(fn, 'rwb+') try: if f.read() == arg: - print "checkok", fn + print("checkok", fn) else: - print "syncing", fn + print("syncing", fn) f = open(fn, 'w') f.write(arg) finally: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit