def unbound_symbols(code, context=None): if context is None: context = Context([], default_options) from Cython.Compiler.ParseTreeTransforms import AnalyseDeclarationsTransform tree = parse_from_strings('(tree fragment)', code) for phase in Pipeline.create_pipeline(context, 'pyx'): if phase is None: continue tree = phase(tree) if isinstance(phase, AnalyseDeclarationsTransform): break try: import builtins except ImportError: import __builtin__ as builtins return tuple(UnboundSymbols()(tree) - set(dir(builtins)))
def unbound_symbols(code, context=None): code = to_unicode(code) if context is None: context = Context([], default_options) from Cython.Compiler.ParseTreeTransforms import AnalyseDeclarationsTransform tree = parse_from_strings('(tree fragment)', code) for phase in Pipeline.create_pipeline(context, 'pyx'): if phase is None: continue tree = phase(tree) if isinstance(phase, AnalyseDeclarationsTransform): break try: import builtins except ImportError: import __builtin__ as builtins return UnboundSymbols()(tree) - set(dir(builtins))
def unbound_symbols(code, context=None): code = to_unicode(code) if context is None: context = Context([], default_options) from Cython.Compiler.ParseTreeTransforms import AnalyseDeclarationsTransform tree = parse_from_strings('(tree fragment)', code) for phase in Pipeline.create_pipeline(context, 'pyx'): if phase is None: continue tree = phase(tree) if isinstance(phase, AnalyseDeclarationsTransform): break symbol_collector = AllSymbols() symbol_collector(tree) unbound = [] try: import builtins except ImportError: import __builtin__ as builtins for name in symbol_collector.names: if not tree.scope.lookup(name) and not hasattr(builtins, name): unbound.append(name) return unbound