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

Method abstract_get_bases

crates/vm/src/protocol/object.rs:438–449  ·  view source on GitHub ↗

abstract_get_bases() has logically 4 return states: 1. getattr(cls, '__bases__') could raise an AttributeError 2. getattr(cls, '__bases__') could raise some other exception 3. getattr(cls, '__bases__') could return a tuple 4. getattr(cls, '__bases__') could return something other than a tuple Only state #3 returns Some(tuple). AttributeErrors are masked by returning None. If an object other than

(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

436 /// If an object other than a tuple comes out of __bases__, then again, None is returned.
437 /// Other exceptions are propagated.
438 fn abstract_get_bases(&self, vm: &VirtualMachine) -> PyResult<Option<PyTupleRef>> {
439 match vm.get_attribute_opt(self.to_owned(), identifier!(vm, __bases__))? {
440 Some(bases) => {
441 // Check if it's a tuple
442 match PyTupleRef::try_from_object(vm, bases) {
443 Ok(tuple) => Ok(Some(tuple)),
444 Err(_) => Ok(None), // Not a tuple, return None
445 }
446 }
447 None => Ok(None), // AttributeError was masked
448 }
449 }
450
451 fn abstract_issubclass(&self, cls: &Self, vm: &VirtualMachine) -> PyResult<bool> {
452 // Store the current derived class to check

Callers 2

check_classMethod · 0.80
abstract_issubclassMethod · 0.80

Calls 3

get_attribute_optMethod · 0.80
SomeClass · 0.50
to_ownedMethod · 0.45

Tested by

no test coverage detected