1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 14:48:49 +00:00

Delete NULL bytes from command.script_parts[0]

The byte sequence in command.script_parts[0] can contain one or more
'\x00' which will cause os.stat(path) to throw this error:

        TypeError: must be encoded string without NULL bytes, not str
This commit is contained in:
ilovezfs 2015-11-29 00:19:58 -08:00
parent 9192b555b5
commit c4007f3456

View File

@ -4,7 +4,8 @@ from thefuck.specific.sudo import sudo_support
@sudo_support
def match(command):
return command.script_parts and os.path.exists(command.script_parts[0]) \
return command.script_parts and os.path.exists(
command.script_parts[0].translate(None, '\x00')) \
and 'command not found' in command.stderr