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

Method _invert

crates/vm/src/vm/vm_ops.rs:533–548  ·  view source on GitHub ↗
(&self, a: &PyObject)

Source from the content-addressed store, hash-verified

531 }
532
533 pub fn _invert(&self, a: &PyObject) -> PyResult {
534 const STR: &str = "Bitwise inversion '~' on bool is deprecated and will be removed in Python 3.16. \
535 This returns the bitwise inversion of the underlying int object and is usually not what you expect from negating a bool. \
536 Use the 'not' operator for boolean negation or ~int(x) if you really want the bitwise inversion of the underlying int.";
537 if a.fast_isinstance(self.ctx.types.bool_type) {
538 _warnings::warn(
539 self.ctx.exceptions.deprecation_warning,
540 STR.to_owned(),
541 1,
542 self,
543 )?;
544 }
545 self.get_special_method(a, identifier!(self, __invert__))?
546 .ok_or_else(|| self.new_unsupported_unary_error(a, "unary ~"))?
547 .invoke((), self)
548 }
549
550 // PyObject_Format
551 pub fn format(&self, obj: &PyObject, format_spec: PyStrRef) -> PyResult<PyStrRef> {

Callers 2

execute_instructionMethod · 0.80
invertFunction · 0.80

Calls 7

fast_isinstanceMethod · 0.80
ok_or_elseMethod · 0.80
get_special_methodMethod · 0.80
warnFunction · 0.50
to_ownedMethod · 0.45
invokeMethod · 0.45

Tested by

no test coverage detected