From 998da59f7c7998ea32dac2b8b2fbf4e5996d9979 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 8 Dec 2023 20:18:29 +0200 Subject: [PATCH] Add support for Python 3.12 --- HISTORY.rst | 1 + platformio/fs.py | 5 +++-- platformio/util.py | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 76c53d72..fc0e1b4d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,6 +20,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. 6.1.12 (2023-??-??) ~~~~~~~~~~~~~~~~~~~ +* Added support for Python 3.12 * Introduced a warning during the verification of MCU maximum RAM usage, signaling when the allocated RAM surpasses 100% (`issue #4791 `_) * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) diff --git a/platformio/fs.py b/platformio/fs.py index 1f43a7a3..27d25a59 100644 --- a/platformio/fs.py +++ b/platformio/fs.py @@ -210,7 +210,7 @@ def change_filemtime(path, mtime): def rmtree(path): - def _onerror(func, path, __): + def _onexc(func, path, _): try: st_mode = os.stat(path).st_mode if st_mode & stat.S_IREAD: @@ -223,4 +223,5 @@ def rmtree(path): err=True, ) - return shutil.rmtree(path, onerror=_onerror) + kwargs = {"onexc" if sys.version_info >= (3, 12) else "onerror": _onexc} + return shutil.rmtree(path, **kwargs) diff --git a/platformio/util.py b/platformio/util.py index bb3679fe..54db102f 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -170,9 +170,8 @@ def items_in_list(needle, haystack): def parse_datetime(datestr): - if "T" in datestr and "Z" in datestr: - return datetime.datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%SZ") - return datetime.datetime.strptime(datestr) + assert "T" in datestr and "Z" in datestr + return datetime.datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%SZ") def merge_dicts(d1, d2, path=None):