Skip to content

Commit

Permalink
Improve git.util.cwd docstring
Browse files Browse the repository at this point in the history
This frames the reentrancy claim in terms of what is similar to and
different from contextlib.chdir (which we would just use, but it is
only available on Python 3.11 and later).
  • Loading branch information
EliahKagan committed Sep 12, 2023
1 parent a59aaea commit 22b8dba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def wrapper(self: "Remote", *args: Any, **kwargs: Any) -> T:

@contextlib.contextmanager
def cwd(new_dir: PathLike) -> Generator[PathLike, None, None]:
"""Context manager to temporarily change directory. Not reentrant."""
"""Context manager to temporarily change directory.
This is similar to contextlib.chdir introduced in Python 3.11, but the context
manager object returned by a single call to this function is not reentrant."""
old_dir = os.getcwd()
os.chdir(new_dir)
try:
Expand Down

0 comments on commit 22b8dba

Please sign in to comment.