From 5f8c97fbaf0d35e415a9d3f18d07d58266c31bbd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 29 Dec 2025 19:06:58 +0200 Subject: [PATCH] Deprecated since Python 3.14: codecs.open() has been superseded by open() --- platformio/cache.py | 5 ++--- platformio/project/integration/generator.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/platformio/cache.py b/platformio/cache.py index 20901545..4b73bd67 100644 --- a/platformio/cache.py +++ b/platformio/cache.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import codecs import hashlib import os from time import time @@ -57,7 +56,7 @@ class ContentCache: cache_path = self.get_cache_path(key) if not os.path.isfile(cache_path): return None - with codecs.open(cache_path, "rb", encoding="utf8") as fp: + with open(cache_path, "r", encoding="utf8") as fp: return fp.read() def set(self, key, data, valid): @@ -78,7 +77,7 @@ class ContentCache: if not os.path.isdir(os.path.dirname(cache_path)): os.makedirs(os.path.dirname(cache_path)) try: - with codecs.open(cache_path, mode="wb", encoding="utf8") as fp: + with open(cache_path, mode="w", encoding="utf8") as fp: fp.write(data) with open(self._db_path, mode="a", encoding="utf8") as fp: fp.write("%s=%s\n" % (str(expire_time), os.path.basename(cache_path))) diff --git a/platformio/project/integration/generator.py b/platformio/project/integration/generator.py index 3cb677f1..53d229ea 100644 --- a/platformio/project/integration/generator.py +++ b/platformio/project/integration/generator.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import codecs import os import sys @@ -167,12 +166,12 @@ class ProjectGenerator: @staticmethod def _render_tpl(tpl_path, tpl_vars): - with codecs.open(tpl_path, "r", encoding="utf8") as fp: + with open(tpl_path, "r", encoding="utf8") as fp: return bottle.template(fp.read(), **tpl_vars) @staticmethod def _merge_contents(dst_path, contents): if os.path.basename(dst_path) == ".gitignore" and os.path.isfile(dst_path): return - with codecs.open(dst_path, "w", encoding="utf8") as fp: + with open(dst_path, "w", encoding="utf8") as fp: fp.write(contents)