hundreds-father-404
03/15/2021, 8:16 PMnative.py Externs.create_exception() method with instead using CPython's eval(code: &str) mechanism, which will reduce FFI boilerplate.
But I'm stuck on escaping of quotes. I'm writing py.eval(&format!("Exception(\"{}\")", msg), and it results in a syntax error if msg has " in it. We need to modify msg so that " is transformed into \". I'm not finding a good way to do this in Rust - the best I've thought of is to map over .chars() and create a new String?fast-nail-55400
03/15/2021, 8:43 PMPyErr? https://docs.rs/cpython/0.5.2/cpython/struct.PyErr.htmlfast-nail-55400
03/15/2021, 8:46 PMExample: return Err(PyErr::new::<exc::TypeError, _>(py, "Error message"));hundreds-father-404
03/16/2021, 1:53 AMException() for the sake of generating a string
But the above problem is solved by using PyModule.call() instead of eval(). Yay!