# HG changeset patch # User Emmanuel Gil Peyrot # Date 1466633124 -3600 # Node ID 624393ed3b0ba5c5a34e0aebaebf47faabe07620 # Parent a7b1db623f417a4617a1a3e892342e687fe0e179 Don’t cast anything to str, except Num for now. diff --git a/src/ast_convert.rs b/src/ast_convert.rs --- a/src/ast_convert.rs +++ b/src/ast_convert.rs @@ -4,6 +4,10 @@ use cpython::{Python, PyObject, PyBool, use cpython::ObjectProtocol; //for call method fn get_str(py: Python, object: PyObject) -> String { + object.extract(py).unwrap() +} + +fn convert_to_str(py: Python, object: PyObject) -> String { let pystring = object.str(py).unwrap(); let mut string = pystring.to_string(py).unwrap(); string.to_mut().to_string() @@ -384,7 +388,9 @@ fn parse_expr(py: Python, ast: PyObject) expr::NameConstant(constant) } else if is_instance(&ast, &num_type) { let n = ast.getattr(py, "n").unwrap(); - let n = get_str(py, n); + // FIXME: we should convert these to either bigint, double or complex. + // TODO: find a suitable bigint library. + let n = convert_to_str(py, n); expr::Num(n) } else if is_instance(&ast, &str_type) { let s = ast.getattr(py, "s").unwrap();