mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Merge branch 'fix/extractall_deprecation_v5.2' into 'release/v5.2'
fix(idf_tools): Patch extractall() deprecation warning (v5.2) See merge request espressif/esp-idf!37885
This commit is contained in:
@ -386,10 +386,7 @@ def get_env_for_extra_paths(extra_paths): # type: (List[str]) -> Dict[str, str]
|
|||||||
"""
|
"""
|
||||||
env_arg = os.environ.copy()
|
env_arg = os.environ.copy()
|
||||||
new_path = os.pathsep.join(extra_paths) + os.pathsep + env_arg['PATH']
|
new_path = os.pathsep.join(extra_paths) + os.pathsep + env_arg['PATH']
|
||||||
if sys.version_info.major == 2:
|
env_arg['PATH'] = new_path
|
||||||
env_arg['PATH'] = new_path.encode('utf8') # type: ignore
|
|
||||||
else:
|
|
||||||
env_arg['PATH'] = new_path
|
|
||||||
return env_arg
|
return env_arg
|
||||||
|
|
||||||
|
|
||||||
@ -430,11 +427,14 @@ def unpack(filename, destination): # type: (str, str) -> None
|
|||||||
archive_obj = ZipFile(filename)
|
archive_obj = ZipFile(filename)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError('Unsupported archive type')
|
raise NotImplementedError('Unsupported archive type')
|
||||||
if sys.version_info.major == 2:
|
|
||||||
# This is a workaround for the issue that unicode destination is not handled:
|
# Handle tar/zip extraction with backward compatibility
|
||||||
# https://bugs.python.org/issue17153
|
if isinstance(archive_obj, tarfile.TarFile) and sys.version_info[:2] >= (3, 12):
|
||||||
destination = str(destination)
|
# Use the tar filter argument for Python 3.12 and later
|
||||||
archive_obj.extractall(destination)
|
archive_obj.extractall(destination, filter='tar')
|
||||||
|
else:
|
||||||
|
archive_obj.extractall(destination)
|
||||||
|
|
||||||
# ZipFile on Unix systems does not preserve file permissions while extracting it
|
# ZipFile on Unix systems does not preserve file permissions while extracting it
|
||||||
# We need to reset the permissions afterward
|
# We need to reset the permissions afterward
|
||||||
if sys.platform != 'win32' and filename.endswith('zip') and isinstance(archive_obj, ZipFile):
|
if sys.platform != 'win32' and filename.endswith('zip') and isinstance(archive_obj, ZipFile):
|
||||||
@ -2847,15 +2847,6 @@ def main(argv): # type: (list[str]) -> None
|
|||||||
# See https://bugs.python.org/issue22490#msg283859.
|
# See https://bugs.python.org/issue22490#msg283859.
|
||||||
os.environ.pop('__PYVENV_LAUNCHER__', None)
|
os.environ.pop('__PYVENV_LAUNCHER__', None)
|
||||||
|
|
||||||
if sys.version_info.major == 2:
|
|
||||||
try:
|
|
||||||
global_idf_tools_path.decode('ascii') # type: ignore
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
fatal('IDF_TOOLS_PATH contains non-ASCII characters: {}'.format(global_idf_tools_path) +
|
|
||||||
'\nThis is not supported yet with Python 2. ' +
|
|
||||||
'Please set IDF_TOOLS_PATH to a directory with an ASCII name, or switch to Python 3.')
|
|
||||||
raise SystemExit(1)
|
|
||||||
|
|
||||||
if CURRENT_PLATFORM is None:
|
if CURRENT_PLATFORM is None:
|
||||||
fatal('Platform {} appears to be unsupported'.format(PYTHON_PLATFORM))
|
fatal('Platform {} appears to be unsupported'.format(PYTHON_PLATFORM))
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
Reference in New Issue
Block a user