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 underrun
Recipients r.david.murray, underrun
Date 2013-08-08.15:23:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1375975389.52.0.486981334706.issue18679@psf.upfronthosting.co.za>
In-reply-to
Content
using repr(x)[1:-1] is not safe for my use case as i need this for encoding and decoding data. the "deserialization" of repr would be eval, and aside from the security issues with that, if I strip the quotes off I can't reliably eval the result and get back the original. On top of that, quote escape handling makes this non-portable to other languages/tools that do understand control character escapes. Consider:

>>> s = """Α""\t'''Ω"""
>>> print(s)
Α""	'''Ω
>>> e = repr(s)[1:-1]
>>> print(e)
Α""\t\'\'\'Ω

how do i know what to quote e with before I eval it to get back the value? I can't even try all the quoting options and stop when i don't get a syntax error because more than one could work and give me a bad result:

>>> d = eval('"{}"'.format(e))
>>> d == s
False
>>> print(d)
Α	'''Ω

Aside from python not being able to handle the repr(x)[1:-1] case itself, the goal is to use output generated in common tools from cut to hadoop where tab is a field separator (aside: wouldn't adoption of ascii 0x1f as a common unit separator be great). Sometimes it is useful to separate newlines in data from a literal new line in formats (again like hadoop or unix utilities) that treat lines as records (and here again ascii 0x1e would have been a nice solution).

But we have to work with what we've got and there are many tools that care about tab separated fields and per line records. In these cases, the right tool for the interoperability job is a codec that simply backslash escapes control characters and nothing else.
History
Date User Action Args
2013-08-08 15:23:09underrunsetrecipients: + underrun, r.david.murray
2013-08-08 15:23:09underrunsetmessageid: <1375975389.52.0.486981334706.issue18679@psf.upfronthosting.co.za>
2013-08-08 15:23:09underrunlinkissue18679 messages
2013-08-08 15:23:08underruncreate