Hi,
Just a note that python-yaml-edit 0.1.3-2 also fails to build against
rust-yaml-edit 0.3.5-1 (now in unstable and testing). We hit this in Ubuntu
when rebuilding it for Python 3.15.
yaml-edit 0.3.3 made the merge-key APIs fallible, and the 0.1.3 bindings in
src/lib.rs still use the old signatures:
error[E0308]: mismatched types
--> src/lib.rs:487:9
MergedMapping::new(self.base.clone(), &self.registry)
expected `MergedMapping<'_>`, found `Result<MergedMapping<'_>,
ResolveError>`
error[E0599]: no method named `base` found for enum `Option<T>`
--> src/lib.rs:525:26 (get_merged)
error[E0599]: no method named `as_mapping` found for enum `Option<T>`
--> src/lib.rs:751:24 (Document::merged)
Upstream already adapted the bindings in "Bump yaml-edit to 0.3.5 and make
the
API Pythonic" (jelmer/yaml-edit-py PR #10), released in 0.2.0 and 0.2.1.
Those releases need pyo3 >= 0.29, so this is the same update as the PyO3
0.29
transition requested here.
Until then, upstream commit 966a4911 ("Bump yaml-edit to 0.3.3", in 0.2.0)
applies cleanly to 0.1.3 for src/lib.rs, the .pyi and the tests (without the
Cargo.toml/Cargo.lock hunks) and makes it build against yaml-edit 0.3.5 with
pyo3 0.28. We are carrying exactly that in Ubuntu as 0.1.3-2ubuntu1. It is
only useful if you need a rebuild before moving to 0.2.x.
Thanks,
Sebastien
Description: Fix the build with yaml-edit 0.3.5
MergedMapping::new, MergedMapping::get_merged and Document::merged now
return a Result. Propagate resolution errors as Python ValueError.
Author: Sebastien Bacher <[email protected]>
Forwarded: no
Last-Update: 2026-11-16
--- python-yaml-edit-0.1.3.orig/src/lib.rs
+++ python-yaml-edit-0.1.3/src/lib.rs
@@ -484,7 +484,10 @@ struct PyMergedMapping {
impl PyMergedMapping {
/// Borrow `base` and `registry` as a `MergedMapping` for a single query.
fn view(&self) -> MergedMapping<'_> {
+ // The view was already resolved successfully when this object was
+ // created, so resolving it again cannot fail.
MergedMapping::new(self.base.clone(), &self.registry)
+ .expect("merged mapping was validated when it was created")
}
}
@@ -520,11 +523,15 @@ impl PyMergedMapping {
/// Look up a nested mapping, returning another merged view that resolves
/// against the same anchors.
- fn get_merged(&self, key: &str) -> Option<PyMergedMapping> {
- self.view().get_merged(key).map(|nested| PyMergedMapping {
+ fn get_merged(&self, key: &str) -> PyResult<Option<PyMergedMapping>> {
+ let nested = self
+ .view()
+ .get_merged(key)
+ .map_err(|e| PyValueError::new_err(e.to_string()))?;
+ Ok(nested.map(|nested| PyMergedMapping {
base: nested.base().clone(),
registry: self.registry.clone(),
- })
+ }))
}
/// The merged keys, in resolution order (direct entries first).
@@ -746,11 +753,15 @@ impl PyDocument {
///
/// The anchor registry is built from the whole document, so aliases
/// pointing at anchors defined elsewhere resolve correctly.
- fn merged(&self) -> Option<PyMergedMapping> {
- self.inner.merged().map(|view| PyMergedMapping {
+ fn merged(&self) -> PyResult<Option<PyMergedMapping>> {
+ let view = self
+ .inner
+ .merged()
+ .map_err(|e| PyValueError::new_err(e.to_string()))?;
+ Ok(view.map(|view| PyMergedMapping {
base: view.as_mapping().base().clone(),
registry: view.registry().clone(),
- })
+ }))
}
fn contains_key(&self, key: &str) -> bool {