[New-bugs-announce] [issue28811] Make pathlib.PurePath.__str__ use shlex.quote
Ram Rachum
report at bugs.python.org
Sun Nov 27 04:33:13 EST 2016
New submission from Ram Rachum:
I have a a PurePath object like so:
path = PurePath('/home/my awesome user/file.txt')
I'm SSHing into a server and I want to remove the file. So I have to do this:
ssh_client.run(f'/bin/rm {shlex.quote(str(path))}')
Which is really long and ugly. (I might have been able to remove the str from there if #28623 wasn't rejected.)
I wish I could do this:
ssh_client.run(f'/bin/rm {path}')
But since my path has a space, that would only be possible if PurePath.__str__ were to use shlex.quote, and put quotes around my path (only if it includes a space).
What do you think about that?
----------
components: Library (Lib)
messages: 281812
nosy: cool-RR, pitrou
priority: normal
severity: normal
status: open
title: Make pathlib.PurePath.__str__ use shlex.quote
type: enhancement
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28811>
_______________________________________
More information about the New-bugs-announce
mailing list