MCPcopy Index your code
hub / github.com/python/cpython / push

Method push

Lib/contextlib.py:505–514  ·  view source on GitHub ↗

Registers a callback with the standard __exit__ method signature. Can suppress exceptions the same way __exit__ method can. Also accepts any object with an __exit__ method (registering a call to the method instead of the object itself).

(self, exit)

Source from the content-addressed store, hash-verified

503 return new_stack
504
505 def push(self, exit):
506 """Registers a callback with the standard __exit__ method signature.
507
508 Can suppress exceptions the same way __exit__ method can.
509 Also accepts any object with an __exit__ method (registering a call
510 to the method instead of the object itself).
511 """
512 exit_method = _lookup_special(exit, '__exit__', exit)
513 self._push_exit_callback(exit_method)
514 return exit # Allow use as a decorator.
515
516 def enter_context(self, cm):
517 """Enters the supplied context manager.

Callers

nothing calls this directly

Calls 2

_push_exit_callbackMethod · 0.95
_lookup_specialFunction · 0.85

Tested by

no test coverage detected