8000 CI - Python deprecations (#9242) · esp8266/Arduino@606324c · GitHub
[go: up one dir, main page]

Skip to content

Commit 606324c

Browse files
authored
CI - Python deprecations (#9242)
py3.13 - 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. py3.12 - 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.
1 parent 8e2094e commit 606324c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

tools/boards.txt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,7 @@ def package ():
18771877
substitution += ',\n'.join(board_items)
18781878
substitution += '\n ],'
18791879

1880-
newfilestr = re.sub(r'"boards":[^\]]*\],', substitution, filestr, re.MULTILINE)
1880+
newfilestr = re.sub(r'"boards":[^\]]*\],', substitution, filestr, flags=re.MULTILINE)
18811881

18821882
# To get consistent indent/formatting read the JSON and write it out programmatically
18831883
if packagegen:

tools/get.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818

1919
verbose = True
2020

21-
if sys.version_info[0] == 3:
22-
from urllib.request import urlretrieve
21+
from urllib.request import urlretrieve
22+
23+
if sys.version_info >= (3,12):
24+
TARFILE_EXTRACT_ARGS = {'filter': 'data'}
2325
else:
24-
# Not Python 3 - today, it is most likely to be Python 2
25-
from urllib import urlretrieve
26+
TARFILE_EXTRACT_ARGS = {}
2627

2728
dist_dir = 'dist/'
2829

@@ -51,9 +52,10 @@ def report_progress(count, blockSize, totalSize):
5152
def unpack(filename, destination):
5253
dirname = ''
5354
print('Extracting {0}'.format(filename))
54-
if filename.endswith('tar.gz'):
55-
tfile = tarfile.open(filename, 'r:gz')
56-
tfile.extractall(destination)
55+
extension = filename.split('.')[-1]
56+
if filename.endswith((f'.tar.{extension}', f'.t{extension}')):
57+
tfile = tarfile.open(filename, f'r:{extension}')
58+
tfile.extractall(destination, **TARFILE_EXTRACT_ARGS)
5759
dirname= tfile.getnames()[0]
5860
elif filename.endswith('zip'):
5961
zfile = zipfile.ZipFile(filename)

0 commit comments

Comments
 (0)
0