Message89690
Thanks for the explanation -- looks like I was way off base on that one.
I took a look at the code you provided but it doesn't work as a drop-in
replacement for _escape_cdata, since that function returns a string
rather than bytes.
However taking your code, calling it _encode_cdata and then refactoring
all calls _encode(_escape_cdata(x), encoding) to _encode_cdata(x,
encoding) seems to do the trick and passes the tests.
Specific example:
- file.write(_encode(_escape_cdata(node.text), encoding))
+ file.write(_encode_cdata(node.text, encoding))
One minor modification is to return the string as is if encoding=None,
just like _encode:
def _encode_cdata(text, encoding):
# escape character data
try:
text = text.replace("&", "&")
text = text.replace("<", "<")
text = text.replace(">", ">")
if encoding:
return text.encode(encoding, "xmlcharrefreplace")
else:
return text
except (TypeError, AttributeError):
_raise_serialization_error(text) |
|
Date |
User |
Action |
Args |
2009-06-24 23:56:06 | jcsalterego | set | recipients:
+ jcsalterego, effbot, pitrou, hodgestar, Neil Muller |
2009-06-24 23:56:05 | jcsalterego | set | messageid: <1245887765.93.0.715142441657.issue6233@psf.upfronthosting.co.za> |
2009-06-24 23:56:04 | jcsalterego | link | issue6233 messages |
2009-06-24 23:56:04 | jcsalterego | create | |
|