On Tue, November 3, 2009 17:19, Binger David wrote: > We could fix this, I think, but I prefer the more direct approach that you suggest below, if it works. The wrappers are there to support "lazy" quoting, so that % arguments like locals() would work without quoting everything in advance. For the format() function, I think we could get by with simply quoting the arguments that are provided. After a little digging I came up with a solution that allows us to keep the wrapper for kwargs. It turns out whatever is generating the exception appears to be looking only for the .keys() method as signature it is dealing with a mapping. I've added a trivial method to _xml_quote_wrapper() and updated the .format() code accordingly in this patch: *** quoted.py.orig 2009-11-03 19:33:06.000000000 -0800 --- quoted.py 2009-11-03 19:36:30.000000000 -0800 *************** *** 55,60 **** --- 55,64 ---- def __getitem__(self, key): return _quote_wrap(self.value[key]) + def keys(self): + """Required to convince other code this is a mapping-like object""" + return [k for k in self.value.iterkeys()] + def _quote_wrap(x): """(x) -> _xml_quote_wrapper | x Not for outside code. *************** *** 73,79 **** """ __slots__ = [] ! def __new__(klass, string=None, encoding=sys.getdefaultencoding(), errors='strict'): if string is None: return xml('') --- 77,83 ---- """ __slots__ = [] ! def __new__(klass, string=None, encoding=sys.getdefaultencoding(), errors='strict'): if string is None: return xml('') *************** *** 119,124 **** --- 123,133 ---- """ return xml(unicode_str.join(self, (xml_quote(item) for item in items))) + def format(self, *args, **kwargs): + quoted_args = tuple(_quote_wrap(arg) for arg in args) + quoted_kwargs = _xml_quote_wrapper(kwargs) + return xml(unicode_str.format(self, *quoted_args, **quoted_kwargs)) + join_xml = xml().join xml.quote = staticmethod(xml_quote)