Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Lib/test/test_sqlite3/test_userfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(?)",
Expand Down
8 changes: 3 additions & 5 deletions stdlib/src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
Loading