From ea4305069aa1f93bd69b9566ad929b072c2b7d13 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 20 May 2025 18:28:34 +0300 Subject: [PATCH 1/3] boards.txt.py - use keywords for re.sub count=... and flags=... https://docs.python.org/3/library/re.html#re.sub > Deprecated since version 3.13: > Passing count and flags as positional arguments is deprecated. > In future Python versions they will be keyword-only parameters. --- tools/boards.txt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/boards.txt.py b/tools/boards.txt.py index 0ccfa8f4d9..3ab2a2f175 100755 --- a/tools/boards.txt.py +++ b/tools/boards.txt.py @@ -1877,7 +1877,7 @@ def package (): substitution += ',\n'.join(board_items) substitution += '\n ],' - newfilestr = re.sub(r'"boards":[^\]]*\],', substitution, filestr, re.MULTILINE) + newfilestr = re.sub(r'"boards":[^\]]*\],', substitution, count=filestr, flags=re.MULTILINE) # To get consistent indent/formatting read the JSON and write it out programmatically if packagegen: From 6b2e1932e360faf89b6f4865ecf15a12b6a48263 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 20 May 2025 18:37:14 +0300 Subject: [PATCH 2/3] get.py tarfile py3.12 extraction filter=... https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extraction_filter > If extraction_filter is None (the default), calling an extraction method without a filter argument > will raise a DeprecationWarning, and fall back to the fully_trusted filter, whose dangerous > behavior matches previous versions of Python. --- tools/get.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/get.py b/tools/get.py index 8276a46f21..81de20e1b9 100755 --- a/tools/get.py +++ b/tools/get.py @@ -18,11 +18,12 @@ verbose = True -if sys.version_info[0] == 3: - from urllib.request import urlretrieve +from urllib.request import urlretrieve + +if sys.version_info >= (3,12): + TARFILE_EXTRACT_ARGS = {'filter': 'data'} else: - # Not Python 3 - today, it is most likely to be Python 2 - from urllib import urlretrieve + TARFILE_EXTRACT_ARGS = {} dist_dir = 'dist/' @@ -51,9 +52,10 @@ def report_progress(count, blockSize, totalSize): def unpack(filename, destination): dirname = '' print('Extracting {0}'.format(filename)) - if filename.endswith('tar.gz'): - tfile = tarfile.open(filename, 'r:gz') - tfile.extractall(destination) + extension = filename.split('.')[-1] + if filename.endswith((f'.tar.{extension}', f'.t{extension}')): + tfile = tarfile.open(filename, f'r:{extension}') + tfile.extractall(destination, **TARFILE_EXTRACT_ARGS) dirname= tfile.getnames()[0] elif filename.endswith('zip'): zfile = zipfile.ZipFile(filename) From 5d6da9c4c7096c244f7384090f4dccd457976f05 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 20 May 2025 18:57:15 +0300 Subject: [PATCH 3/3] fixup! boards.txt.py - use keywords for re.sub count=... and flags=... --- tools/boards.txt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/boards.txt.py b/tools/boards.txt.py index 3ab2a2f175..576e02a614 100755 --- a/tools/boards.txt.py +++ b/tools/boards.txt.py @@ -1877,7 +1877,7 @@ def package (): substitution += ',\n'.join(board_items) substitution += '\n ],' - newfilestr = re.sub(r'"boards":[^\]]*\],', substitution, count=filestr, flags=re.MULTILINE) + newfilestr = re.sub(r'"boards":[^\]]*\],', substitution, filestr, flags=re.MULTILINE) # To get consistent indent/formatting read the JSON and write it out programmatically if packagegen: