1. Ronny Pfannschmidt
  2. execnet-patches

Commits

Ronny Pfannschmidt  committed 843311f

initial

  • Participants
  • Branches default

Comments (0)

Files changed (3)

File .hgignore

View file
+^\.hg
+^\.mq
+syntax: glob
+status
+guards

File find-globals-no-ast

View file
+# HG changeset patch
+# Parent c2446980981075060ec9188b33b50135c4909df7
+diff --git a/execnet/gateway.py b/execnet/gateway.py
+--- a/execnet/gateway.py
++++ b/execnet/gateway.py
+@@ -165,20 +165,15 @@ def rinfo_source(channel):
+ 
+ def _find_non_builtin_globals(source, codeobj):
+     try:
+-        import ast
+-    except ImportError:
+-        return None
+-    try:
+         import __builtin__
+     except ImportError:
+         import builtins as __builtin__
+ 
+-    vars = dict.fromkeys(codeobj.co_varnames)
+     all = []
+-    for node in ast.walk(ast.parse(source)):
+-        if (isinstance(node, ast.Name) and node.id not in vars and
+-            node.id not in __builtin__.__dict__):
+-            all.append(node.id)
++    for name in codeobj.co_names:
++        if name not in __builtin__.__dict__ \
++           and name not in codeobj.co_varnames:
++            all.append(name)
+     return all
+ 
+ 
+diff --git a/testing/test_basics.py b/testing/test_basics.py
+--- a/testing/test_basics.py
++++ b/testing/test_basics.py
+@@ -265,9 +265,6 @@ class TestSourceOfFunction(object):
+ 
+ class TestGlobalFinder(object):
+ 
+-    def setup_class(cls):
+-        py.test.importorskip('ast')
+-
+     def check(self, func):
+         src = py.code.Source(func)
+         code = py.code.Code(func)

File series

View file
+find-globals-no-ast