##// END OF EJS Templates
rust-utils: introduce a debug util to print the python stack trace...
Raphaël Gomès -
r43545:97097897 default
parent child Browse files
Show More
@@ -0,0 +1,13 b''
1 use cpython::{PyDict, PyObject, PyResult, PyTuple, Python};
2
3 #[allow(unused)]
4 pub fn print_python_trace(py: Python) -> PyResult<PyObject> {
5 eprintln!("===============================");
6 eprintln!("Printing Python stack from Rust");
7 eprintln!("===============================");
8 let traceback = py.import("traceback")?;
9 let sys = py.import("sys")?;
10 let kwargs = PyDict::new(py);
11 kwargs.set_item(py, "file", sys.get(py, "stderr")?)?;
12 traceback.call(py, "print_stack", PyTuple::new(py, &[]), Some(&kwargs))
13 }
@@ -35,6 +35,7 b' pub mod discovery;'
35 pub mod exceptions;
35 pub mod exceptions;
36 pub mod filepatterns;
36 pub mod filepatterns;
37 pub mod parsers;
37 pub mod parsers;
38 pub mod utils;
38
39
39 py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| {
40 py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| {
40 m.add(
41 m.add(
General Comments 0
You need to be logged in to leave comments. Login now