解决tools/keil.py中python3不兼容python2的str.decode()

This commit is contained in:
latercomer 2024-07-10 14:21:56 +08:00 committed by Rbb666
parent 08c96e5e47
commit ba105bc686
1 changed files with 8 additions and 2 deletions

View File

@ -87,12 +87,18 @@ def MDK4AddGroupForFN(ProjectFiles, parent, name, filename, project_path):
if ProjectFiles.count(obj_name):
name = basename + '_' + name
ProjectFiles.append(obj_name)
file_name.text = name.decode(fs_encoding)
try: # python 2
file_name.text = name.decode(fs_encoding)
except: # python 3
file_name.text = name
file_type = SubElement(file, 'FileType')
file_type.text = '%d' % _get_filetype(name)
file_path = SubElement(file, 'FilePath')
try: # python 2
file_path.text = path.decode(fs_encoding)
except: # python 3
file_path.text = path
file_path.text = path.decode(fs_encoding)
return group