diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index bd1dbcd626..9ca02cea35 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -909,8 +909,6 @@ def handle(exc): self.assertEqual(exc.object, input) self.assertEqual(exc.reason, "surrogates not allowed") - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_badregistercall(self): # enhance coverage of: # Modules/_codecsmodule.c::register_error() diff --git a/vm/src/stdlib/codecs.rs b/vm/src/stdlib/codecs.rs index 468b5dda6e..46b1608f24 100644 --- a/vm/src/stdlib/codecs.rs +++ b/vm/src/stdlib/codecs.rs @@ -67,10 +67,14 @@ mod _codecs { } #[pyfunction] - fn register_error(name: PyStrRef, handler: PyObjectRef, vm: &VirtualMachine) { + fn register_error(name: PyStrRef, handler: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> { + if !handler.is_callable() { + return Err(vm.new_type_error("handler must be callable".to_owned())); + } vm.state .codec_registry .register_error(name.as_str().to_owned(), handler); + Ok(()) } #[pyfunction]