Skip to content

Commit 49aad6c

Browse files
committed
internal docs and coverage
1 parent fec85ec commit 49aad6c

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/impl_/pyclass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ impl<
12361236
const IMPLEMENTS_TOPYOBJECT: bool,
12371237
> PyClassGetterGenerator<ClassT, Py<U>, Offset, true, IMPLEMENTS_TOPYOBJECT>
12381238
{
1239-
/// Py<T> fields have a potential optimization to use Python's "struct members" to read
1239+
/// `Py<T>` fields have a potential optimization to use Python's "struct members" to read
12401240
/// the field directly from the struct, rather than using a getter function.
12411241
///
12421242
/// This is the most efficient operation the Python interpreter could possibly do to
@@ -1261,7 +1261,7 @@ impl<
12611261
}
12621262
}
12631263

1264-
/// Field is not Py<T>; try to use `ToPyObject` to avoid potentially expensive clones of containers like `Vec`
1264+
/// Field is not `Py<T>`; try to use `ToPyObject` to avoid potentially expensive clones of containers like `Vec`
12651265
impl<ClassT: PyClass, FieldT: ToPyObject, Offset: OffsetCalculator<ClassT, FieldT>>
12661266
PyClassGetterGenerator<ClassT, FieldT, Offset, false, true>
12671267
{

tests/test_getter_setter.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,25 @@ fn borrowed_value_with_lifetime_of_self() {
258258
py_run!(py, inst, "assert inst.value == 'value'");
259259
});
260260
}
261+
262+
#[test]
263+
fn frozen_py_field_get() {
264+
#[pyclass(frozen)]
265+
struct FrozenPyField {
266+
#[pyo3(get)]
267+
value: Py<PyAny>,
268+
}
269+
270+
Python::with_gil(|py| {
271+
let inst = Py::new(
272+
py,
273+
FrozenPyField {
274+
value: "value".into_py(py),
275+
},
276+
)
277+
.unwrap()
278+
.to_object(py);
279+
280+
py_run!(py, inst, "assert inst.value == 'value'");
281+
});
282+
}

0 commit comments

Comments
 (0)