Message89585
Did you look at the 1.3 alpha code base when you came up with this idea?
Unfortunately, 1.3's _encode is used for a different purpose...
I don't have time to test it tonight, but I suspect that 1.3's
escape_data/escape_attrib functions might work better under 3.X; they do
the text.replace dance first, and then an explicit text.encode(encoding,
"xmlcharrefreplace") at the end. E.g.
def _escape_cdata(text, encoding):
# escape character data
try:
# it's worth avoiding do-nothing calls for strings that are
# shorter than 500 character, or so. assume that's, by far,
# the most common case in most applications.
if "&" in text:
text = text.replace("&", "&")
if "<" in text:
text = text.replace("<", "<")
if ">" in text:
text = text.replace(">", ">")
return text.encode(encoding, "xmlcharrefreplace")
except (TypeError, AttributeError):
_raise_serialization_error(text) |
|
Date |
User |
Action |
Args |
2009-06-21 21:42:04 | effbot | set | recipients:
+ effbot, pitrou, hodgestar, Neil Muller |
2009-06-21 21:42:04 | effbot | set | messageid: <1245620524.03.0.89226197284.issue6233@psf.upfronthosting.co.za> |
2009-06-21 21:42:03 | effbot | link | issue6233 messages |
2009-06-21 21:42:02 | effbot | create | |
|