Mercurial > public > mercurial-scm > hg
comparison rust/hg-cpython/src/revlog.rs @ 47305:33e7508b0ae9
hg-cpython: fix new occuring TypeError
dd339191f2dc introduced a minor refactoring of error types that highlighted
a fragile error creation mechanism that was in place in the Rust `MixedIndex`.
`PyErr::from_instance` also accepts a Python class, as long as it's an
`Exception` class. Before the aforementioned commit, we never ran into a case
where this duck-typing mechanism failed. We rectify this behavior by doing the
instantiation ourselves.
Differential Revision: https://phab.mercurial-scm.org/D10764
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Fri, 21 May 2021 17:37:53 +0200 |
parents | 9d1a8829f959 |
children | 3fffb48539ee |
comparison
equal
deleted
inserted
replaced
47304:73f52278a158 | 47305:33e7508b0ae9 |
---|---|
467 match py | 467 match py |
468 .import("mercurial.error") | 468 .import("mercurial.error") |
469 .and_then(|m| m.get(py, "RevlogError")) | 469 .and_then(|m| m.get(py, "RevlogError")) |
470 { | 470 { |
471 Err(e) => e, | 471 Err(e) => e, |
472 Ok(cls) => PyErr::from_instance(py, cls), | 472 Ok(cls) => PyErr::from_instance( |
473 py, | |
474 cls.call(py, (py.None(),), None).ok().into_py_object(py), | |
475 ), | |
473 } | 476 } |
474 } | 477 } |
475 | 478 |
476 fn rev_not_in_index(py: Python, rev: Revision) -> PyErr { | 479 fn rev_not_in_index(py: Python, rev: Revision) -> PyErr { |
477 PyErr::new::<ValueError, _>( | 480 PyErr::new::<ValueError, _>( |