MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / normalize

Method normalize

src/err.rs:333–340  ·  view source on GitHub ↗

Normalizes the error. This ensures that the exception value is an instance of the exception type.

(&mut self, py: Python)

Source from the content-addressed store, hash-verified

331
332 /// Normalizes the error. This ensures that the exception value is an instance of the exception type.
333 pub fn normalize(&mut self, py: Python) {
334 // The normalization helper function involves temporarily moving out of the &mut self,
335 // which requires some unsafe trickery:
336 unsafe {
337 std::ptr::write(self, std::ptr::read(self).into_normalized(py));
338 }
339 // This is safe as long as normalized() doesn't unwind due to a panic.
340 }
341
342 /// Helper function for normalizing the error by deconstructing and reconstructing the PyErr.
343 /// Must not panic for safety in normalize()

Callers 1

instanceMethod · 0.80

Calls 2

writeFunction · 0.85
into_normalizedMethod · 0.80

Tested by

no test coverage detected