From c9b3e4ed659973abcd0f5632171a8d74954f869e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 31 Jul 2023 19:10:05 +0300 Subject: [PATCH] Update code in accordance to the Python 3.11 --- platformio/fs.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/platformio/fs.py b/platformio/fs.py index 1f43a7a3..bb38a723 100644 --- a/platformio/fs.py +++ b/platformio/fs.py @@ -29,15 +29,16 @@ from platformio.compat import IS_WINDOWS class cd: - def __init__(self, new_path): - self.new_path = new_path - self.prev_path = os.getcwd() + def __init__(self, path): + self.path = path + self._old_cwd = [] def __enter__(self): - os.chdir(self.new_path) + self._old_cwd.append(os.getcwd()) + os.chdir(self.path) - def __exit__(self, etype, value, traceback): - os.chdir(self.prev_path) + def __exit__(self, *excinfo): + os.chdir(self._old_cwd.pop()) def get_source_dir():