Fix regex match and decoding in install.py

- Changed the regex match to search for bytes instead of string.
- Added a condition to decode the pythonCmd only if no error occurred.
This commit is contained in:
bobo.yang 2023-08-10 08:31:11 +08:00
parent a5eaa6ec17
commit ffeb632ec6

View File

@ -149,7 +149,7 @@ def virtualenv_create_venv(pythoncmd, venvdir, envname):
return False return False
def extract_actual_location(text): def extract_actual_location(text):
match = re.search(r'Actual location:\s+"(.*?)"', text) match = re.search(rb'Actual location:\s+"(.*?)"', text)
if match: if match:
return match.group(1) return match.group(1)
else: else:
@ -193,6 +193,8 @@ def virtualenv_create_venv(pythoncmd, venvdir, envname):
print('create env failed') print('create env failed')
print(error) print(error)
return False return False
else:
pythonCmd = pythonCmd.decode()
return pythonCmd return pythonCmd
except Exception as error: except Exception as error:
print('create env failed') print('create env failed')