[issue28811] Make pathlib.PurePath.__str__ use shlex.quote

2016-11-28 Thread Ram Rachum
Ram Rachum added the comment: I understand now, you're completely right. This change would break the entire world :) -- ___ Python tracker ___

[issue28811] Make pathlib.PurePath.__str__ use shlex.quote

2016-11-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: open(str(path)) -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue28811] Make pathlib.PurePath.__str__ use shlex.quote

2016-11-27 Thread Ram Rachum
Ram Rachum added the comment: "This will break any code that pass str(path) to API that doesn't support pathlib." I don't understand. Can you give a concrete example of code it would break? -- ___ Python tracker

[issue28811] Make pathlib.PurePath.__str__ use shlex.quote

2016-11-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This will break any code that pass str(path) to API that doesn't support pathlib. In your case you can introduce a short alias: q = shlex.quote ssh_client.run(f'/bin/rm {q(str(path))}') Or add more convenient helper: def q(path):

[issue28811] Make pathlib.PurePath.__str__ use shlex.quote

2016-11-27 Thread Ram Rachum
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.