diff --git a/Lib/test/test_sqlite3/test_userfunctions.py b/Lib/test/test_sqlite3/test_userfunctions.py index 7b092365d4..e8b98a66a5 100644 --- a/Lib/test/test_sqlite3/test_userfunctions.py +++ b/Lib/test/test_sqlite3/test_userfunctions.py @@ -354,8 +354,6 @@ def test_return_non_contiguous_blob(self): cur = self.con.execute("select return_noncont_blob()") cur.fetchone() - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_param_surrogates(self): self.assertRaisesRegex(UnicodeEncodeError, "surrogates not allowed", self.con.execute, "select spam(?)", diff --git a/stdlib/src/sqlite.rs b/stdlib/src/sqlite.rs index cec1f04ed9..073975f8fe 100644 --- a/stdlib/src/sqlite.rs +++ b/stdlib/src/sqlite.rs @@ -2965,12 +2965,10 @@ mod _sqlite { } fn str_to_ptr_len(s: &PyStr, vm: &VirtualMachine) -> PyResult<(*const libc::c_char, i32)> { - let s = s - .to_str() - .ok_or_else(|| vm.new_unicode_encode_error("surrogates not allowed"))?; - let len = c_int::try_from(s.len()) + let s_str = s.try_to_str(vm)?; + let len = c_int::try_from(s_str.len()) .map_err(|_| vm.new_overflow_error("TEXT longer than INT_MAX bytes"))?; - let ptr = s.as_ptr().cast(); + let ptr = s_str.as_ptr().cast(); Ok((ptr, len)) }