Skip to content

Commit 55f94bc

Browse files
Apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
1 parent 1b0a942 commit 55f94bc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/py_object_sort.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct PyObjectSort {
4747
impl Debug for PyObjectSort {
4848
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4949
let hashable_to_index =
50-
Python::with_gil(|py| self.hashable_to_index.bind(py).str().unwrap().to_string());
50+
Python::with_gil(|py| self.hashable_to_index.bind(py).str().map_or_else(|_| "<error>".to_string(), |s| s.to_string()));
5151
f.debug_struct("PyObjectSort")
5252
.field("objects", &self.objects)
5353
.field("id_to_index", &self.id_to_index)
@@ -165,6 +165,7 @@ impl PyObjectSort {
165165
fn __clear__<'py>(&mut self, py: Python<'py>) {
166166
self.hashable_to_index.bind(py).clear();
167167
self.objects.lock().unwrap().clear();
168+
self.id_to_index.lock().unwrap().clear();
168169
}
169170
}
170171

0 commit comments

Comments
 (0)