Mercurial > hg
view rust/hg-cpython/src/utils.rs @ 43424:0836efe4967b
rust-cpython: add generation counter to leaked reference
This counter increments on borrow_mut() to invalidate existing leaked
references. This is modeled after the iterator invalidation in Python.
The other checks will be adjusted by the subsequent patches.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 05 Oct 2019 08:27:57 -0400 |
parents | 970978975574 |
children | d738b7a18438 |
line wrap: on
line source
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)) }