[New-bugs-announce] [issue25269] Add method to detect if a string contains surrogates

R. David Murray report at bugs.python.org
Tue Sep 29 14:48:03 CEST 2015


New submission from R. David Murray:

Because surrogates are in several contexts used to "smuggle" bytes through string APIs using surrogateescape, it is very useful to be able to determine if a given string contains surrogates.  The email package, for example, uses different logic to handle strings that contain smuggled bytes and strings that don't when serializing a Message object.  Currently it uses x.encode() and checks for an exception (we determined that for CPython this was the most efficient method to check).  It would be better, I think, to have a dedicated method on str for this, among other reasons so that different python implementations could optimize it appropriately.

(Note that another aspect of dealing with surrogateescaped strings is discussed in issue 18814.)

----------
components: Interpreter Core
messages: 251853
nosy: r.david.murray
priority: normal
severity: normal
status: open
title: Add method to detect if a string contains surrogates
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25269>
_______________________________________


More information about the New-bugs-announce mailing list