From 45a9aa536f5e1bb014219450d01276aa919b24ff Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 29 Aug 2009 14:16:54 -0500 Subject: [PATCH] fix need for py import --HG-- branch : trunk --- py/execnet/gateway.py | 10 +++++++++- py/execnet/script/socketserver.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/py/execnet/gateway.py b/py/execnet/gateway.py index 2b35ac119..9a85c9e9d 100644 --- a/py/execnet/gateway.py +++ b/py/execnet/gateway.py @@ -5,6 +5,7 @@ import traceback import atexit import weakref import __future__ +import sys # note that the whole code of this module (as well as some # other modules) execute not only on the local side but @@ -23,6 +24,13 @@ if 'ThreadOut' not in globals(): from py.__.execnet.message import Message ThreadOut = py._thread.ThreadOut +if sys.version_info > (3, 0): + exec """def do_exec(co, loc): + exec(co, loc)""" +else: + exec """def do_exec(co, loc): + exec co in loc""" + import os debug = 0 # open('/tmp/execnet-debug-%d' % os.getpid() , 'wa') @@ -237,7 +245,7 @@ class Gateway(object): try: co = compile(source+'\n', '', 'exec', __future__.CO_GENERATOR_ALLOWED) - py.test.exec_(co, loc) + do_exec(co, loc) finally: close() self._trace("execution finished:", repr(source)[:50]) diff --git a/py/execnet/script/socketserver.py b/py/execnet/script/socketserver.py index 7c3997830..c11ab8093 100755 --- a/py/execnet/script/socketserver.py +++ b/py/execnet/script/socketserver.py @@ -30,7 +30,7 @@ if sys.version_info > (3, 0): exec(source, locs)""") else: exec("""def exec_(source, locs): - exec source, locs""") + exec source in locs""") def exec_from_one_connection(serversock): print_(progname, 'Entering Accept loop', serversock.getsockname())