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

Method cursor

crates/stdlib/src/_sqlite3.rs:1022–1050  ·  view source on GitHub ↗
(
            zelf: PyRef<Self>,
            args: CursorArgs,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1020
1021 #[pymethod]
1022 fn cursor(
1023 zelf: PyRef<Self>,
1024 args: CursorArgs,
1025 vm: &VirtualMachine,
1026 ) -> PyResult<PyObjectRef> {
1027 zelf.db_lock(vm).map(drop)?;
1028
1029 let factory = match args.factory {
1030 OptionalArg::Present(f) => f,
1031 OptionalArg::Missing => Cursor::class(&vm.ctx).to_owned().into(),
1032 };
1033
1034 let cursor = factory.call((zelf.clone(),), vm)?;
1035
1036 if !cursor.class().fast_issubclass(Cursor::class(&vm.ctx)) {
1037 return Err(vm.new_type_error(format!(
1038 "factory must return a cursor, not {}",
1039 cursor.class()
1040 )));
1041 }
1042
1043 if let Some(cursor_ref) = cursor.downcast_ref::<Cursor>()
1044 && let Some(factory) = zelf.row_factory.to_owned()
1045 {
1046 let _ = unsafe { cursor_ref.row_factory.swap(Some(factory)) };
1047 }
1048
1049 Ok(cursor)
1050 }
1051
1052 #[pymethod]
1053 fn blobopen(

Calls 10

db_lockMethod · 0.80
fast_issubclassMethod · 0.80
ErrClass · 0.50
SomeClass · 0.50
mapMethod · 0.45
to_ownedMethod · 0.45
callMethod · 0.45
cloneMethod · 0.45
classMethod · 0.45
swapMethod · 0.45