mirror of
https://github.com/gryf/mc_adbfs.git
synced 2025-12-18 20:10:21 +01:00
Fix bad filenames for Python3.
In Python3, if there are filenames encoded with 8-bit encodings, there might be an issues with converting them into unicode objects. This is a workaround on this subject. Python2 is not affected. Other than that, there was tests added to cover this case, appropriate Makefile which automate creating venvs for both: Python 2 and 3, and also there is a check against pep8 rules using flake8.
This commit is contained in:
12
adbfs
12
adbfs
@@ -17,7 +17,7 @@ import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
__version__ = 0.11
|
||||
__version__ = 0.12
|
||||
|
||||
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
|
||||
|
||||
@@ -30,7 +30,15 @@ def check_output(command_list, stderr=None):
|
||||
"""
|
||||
result = subprocess.check_output(command_list, stderr=stderr)
|
||||
if not isinstance(result, str):
|
||||
result = result.decode('utf-8')
|
||||
_result = []
|
||||
for t in result.split(b'\n'):
|
||||
if not t:
|
||||
continue
|
||||
try:
|
||||
_result.append(t.decode('utf-8'))
|
||||
except UnicodeDecodeError:
|
||||
_result.append(t.decode('iso-8859-1'))
|
||||
result = '\n'.join(_result) + '\n'
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user