This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Jonas Thiem
Recipients Jonas Thiem, The Compiler
Date 2015-11-06.12:52:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1446814343.82.0.823951892686.issue25567@psf.upfronthosting.co.za>
In-reply-to
Content
Demonstration:

>>> import shlex
>>> shlex.quote(b"abc")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.4/shlex.py", line 285, in quote
    if _find_unsafe(s) is None:
TypeError: can't use a string pattern on a bytes-like object
>>>

Your question is now probably, why would anyone not want to use unicode strings here?

The reason is that for some operations (e.g. file access to some known paths) decoding and encoding from/to any sort of unicode interpretation can be lossy, specifically when the file path on the filesystem has broken/mixed encoding characters. In such a case, the shell command might need to be supplied as bytestring to ensure it is sent exactly as-is so such broken files can still be dealt with, without the Unicode interpretation possibly deforming the path in some bytes.

Since shlex.quote seems targeted at shell usage, it should therefore support this.
History
Date User Action Args
2015-11-06 12:52:23Jonas Thiemsetrecipients: + Jonas Thiem, The Compiler
2015-11-06 12:52:23Jonas Thiemsetmessageid: <1446814343.82.0.823951892686.issue25567@psf.upfronthosting.co.za>
2015-11-06 12:52:23Jonas Thiemlinkissue25567 messages
2015-11-06 12:52:23Jonas Thiemcreate