MCPcopy Index your code
hub / github.com/RustPython/RustPython / unregister_error

Method unregister_error

crates/vm/src/codecs.rs:380–397  ·  view source on GitHub ↗
(&self, name: &str, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

378 }
379
380 pub fn unregister_error(&self, name: &str, vm: &VirtualMachine) -> PyResult<bool> {
381 const BUILTIN_ERROR_HANDLERS: &[&str] = &[
382 "strict",
383 "ignore",
384 "replace",
385 "xmlcharrefreplace",
386 "backslashreplace",
387 "namereplace",
388 "surrogatepass",
389 "surrogateescape",
390 ];
391 if BUILTIN_ERROR_HANDLERS.contains(&name) {
392 return Err(vm.new_value_error(format!(
393 "cannot un-register built-in error handler '{name}'"
394 )));
395 }
396 Ok(self.inner.write().errors.remove(name).is_some())
397 }
398
399 pub fn lookup_error_opt(&self, name: &str) -> Option<PyObjectRef> {
400 self.inner.read().errors.get(name).cloned()

Callers 1

_unregister_errorFunction · 0.80

Calls 4

ErrClass · 0.50
containsMethod · 0.45
removeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected