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

Method py_new

crates/stdlib/src/_sqlite3.rs:893–921  ·  view source on GitHub ↗
(cls: &Py<PyType>, args: Self::Args, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

891 type Args = ConnectArgs;
892
893 fn py_new(cls: &Py<PyType>, args: Self::Args, vm: &VirtualMachine) -> PyResult<Self> {
894 let text_factory = PyStr::class(&vm.ctx).to_owned().into_object();
895
896 // For non-subclassed Connection, initialize in __new__
897 // For subclassed Connection, leave db as None and require __init__ to be called
898 let is_base_class = cls.is(Connection::class(&vm.ctx));
899
900 let db = if is_base_class {
901 // Initialize immediately for base class
902 Some(Connection::initialize_db(&args, vm)?)
903 } else {
904 // For subclasses, require __init__ to be called
905 None
906 };
907
908 let initialized = db.is_some();
909
910 Ok(Self {
911 db: PyMutex::new(db),
912 initialized: Radium::new(initialized),
913 detect_types: Radium::new(args.detect_types),
914 isolation_level: PyAtomicRef::from(args.isolation_level),
915 check_same_thread: Radium::new(args.check_same_thread),
916 thread_ident: PyMutex::new(std::thread::current().id()),
917 row_factory: PyAtomicRef::from(None),
918 text_factory: PyAtomicRef::from(text_factory),
919 autocommit: PyMutex::new(args.autocommit),
920 })
921 }
922 }
923
924 impl Callable for Connection {

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
isMethod · 0.80
ok_or_elseMethod · 0.80
SomeClass · 0.50
into_objectMethod · 0.45
to_ownedMethod · 0.45
idMethod · 0.45
cloneMethod · 0.45
innerMethod · 0.45

Tested by

no test coverage detected