Skip to content

Commit

Permalink
Add chdir context handler in devpi_common.contextlib.
Browse files Browse the repository at this point in the history
Starting with Python 3.11 the original from contextlib is used.
  • Loading branch information
fschulze committed Oct 11, 2023
1 parent 50b5865 commit ad591ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions common/devpi_common/contextlib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from contextlib import contextmanager
try:
from contextlib import chdir
except ImportError:
@contextmanager
def chdir(path):
old = os.getcwd()
try:
os.chdir(path)
yield old
finally:
os.chdir(old)
import os
1 change: 1 addition & 0 deletions common/news/chdir.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``chdir`` context handler in devpi_common.contextlib. Starting with Python 3.11 the original from ``contextlib`` is used.

0 comments on commit ad591ac

Please sign in to comment.