rust/hg-cpython/src/utils.rs
author Rapha?l Gom?s <rgomes@octobus.net>
Tue, 14 Jan 2020 16:58:07 +0100
changeset 44137 3bd77c64bc74
parent 43251 970978975574
child 44505 d738b7a18438
permissions -rw-r--r--
rust-filepatterns: remove bridge code for filepatterns-related functions These functions will be used internally by `hg-core` without needed to be exposed to Python. Differential Revision: https://phab.mercurial-scm.org/D7868

use cpython::{PyDict, PyObject, PyResult, PyTuple, Python};

#[allow(unused)]
pub fn print_python_trace(py: Python) -> PyResult<PyObject> {
    eprintln!("===============================");
    eprintln!("Printing Python stack from Rust");
    eprintln!("===============================");
    let traceback = py.import("traceback")?;
    let sys = py.import("sys")?;
    let kwargs = PyDict::new(py);
    kwargs.set_item(py, "file", sys.get(py, "stderr")?)?;
    traceback.call(py, "print_stack", PyTuple::new(py, &[]), Some(&kwargs))
}