def prase_text_complete(text): status = ffi.new("ParseStatus[1]") s = rstring_p(text) orig_stderr = sys.stderr sys.stderr = None with protected(s): lib.R_ParseVector(s, -1, status, lib.R_NilValue) sys.stderr = orig_stderr return status[0] != 2
def rparse_p(s): ensure_initialized() status = ffi.new("ParseStatus[1]") s = lib.Rf_mkString(utf8tosystem(s)) with protected(s): with capture_console(): # need to capture stderr ret = lib.R_ParseVector(s, -1, status, lib.R_NilValue) if status[0] != lib.PARSE_OK: err = read_stderr().strip() or "Error" raise RuntimeError("{}".format(err)) return ret