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
Prev Previous commit
Next Next commit
Improve git.util.cwd docstring
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
commit 22b8dba6b4c73d04f3dbfabbb858fb5316fec711
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