'None', 'False', 'True', 'abs', 'all', 'any', 'apply', 'basestring', 'bin', 'bool', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals', 'long', 'map', 'max', 'min', 'next', 'object', 'oct', 'ord', 'bytearray', 'pow', 'print', 'property', 'range', 'reduce', 'repr', 'reversed', 'round', 'sequenceiterator', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'zip', '__name__', 'NotImplemented', 'compile', '__import__', # We disallow importing separately, it's too hard to do here '__cffi_backend_extern_py', # This gets added with cpython / cffi 1.6+ and is pretty crucial. } if is_py3: _WHITELISTED_BUILTINS |= {'bytes', 'exec'} # These are needed too # Have to be more careful with encodings in python 3. ffi_to_string = lambda c: ffi.string(c).decode('utf-8') ffi_from_string = lambda s: ffi.new('char[]', s.encode('utf-8')) else: ffi_to_string = ffi.string ffi_from_string = lambda s: ffi.new('char[]', s) builtins.range = builtins.xrange # Used to indicate that parsing of a target is deferred because it requires another target. _DEFER_PARSE = '_DEFER_' _FFI_DEFER_PARSE = ffi_from_string(_DEFER_PARSE) @ffi.def_extern('ParseFile') def parse_file(c_filename, c_package_name, c_package): try: filename = ffi_to_string(c_filename)