Skip to content
Merged
Changes from 1 commit
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
Next Next commit
check_exact
  • Loading branch information
youknowone committed Jun 29, 2025
commit 8abf2daf4ec41861824b53f6cf0db6671ec76adc
6 changes: 6 additions & 0 deletions vm/src/builtins/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ impl PyType {
}

impl Py<PyType> {
/// Equivalent to CPython's PyType_CheckExact macro
/// Checks if obj is exactly a type (not a subclass)
pub fn check_exact<'a>(obj: &'a PyObject, vm: &VirtualMachine) -> Option<&'a Py<PyType>> {
obj.downcast_ref_if_exact::<PyType>(vm)
}

/// Determines if `subclass` is actually a subclass of `cls`, this doesn't call __subclasscheck__,
/// so only use this if `cls` is known to have not overridden the base __subclasscheck__ magic
/// method.
Expand Down