Skip to content
Myr

#2447 Forward exception data to exit stack when calling `__exit__`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michele Bianchi · committed by Michele Bianchi · parent 16fe802 · Browse files · 1 file+22 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+22 added−3 removed

  • other:+22 added−3 removed

1 file+22 added−3 removed

modified:src/click/core.py+22 added-3 removed
481 unmodified lines
482 self,483 exc_type: type[BaseException] | None,484 exc_value: BaseException | None,485 tb: TracebackType | None,486 ) -> None:486 ) -> bool | None:487 self._depth -= 1488 exit_result: bool | None = None489 if self._depth == 0:489 self.close()490 exit_result = self._close_with_exception_info(exc_type, exc_value, tb)491 pop_context()492493 return exit_result494495 @contextmanager496 def scope(self, cleanup: bool = True) -> cabc.Iterator[Context]:497 """This helper method can be used with the context object to promote498 it to the current thread local (see :func:`get_current_context`).
118 unmodified lines
617 """Invoke all close callbacks registered with618 :meth:`call_on_close`, and exit all context managers entered619 with :meth:`with_resource`.620 """618 self._exit_stack.close()621 self._close_with_exception_info(None, None, None)622623 def _close_with_exception_info(624 self,625 exc_type: type[BaseException] | None,626 exc_value: BaseException | None,627 tb: TracebackType | None,628 ) -> bool | None:629 """Unwind the exit stack by calling its :meth:`__exit__` providing the exception630 information to allow for exception handling by the various resources registered631 using :meth;`with_resource`632633 :return: Whatever ``exit_stack.__exit__()`` returns.634 """635 exit_result = self._exit_stack.__exit__(exc_type, exc_value, tb)636 # In case the context is reused, create a new exit stack.637 self._exit_stack = ExitStack()638639 return exit_result640641 @property642 def command_path(self) -> str:643 """The computed command path. This is used for the ``usage``644 information on the help page. It's automatically created by
2703 unmodified lines