Index: saxutils.py =================================================================== --- saxutils.py (revision 74182) +++ saxutils.py (working copy) @@ -83,10 +83,7 @@ class XMLGenerator(handler.ContentHandler): - def __init__(self, out=None, encoding="iso-8859-1"): - if out is None: - import sys - out = sys.stdout + def __init__(self, out, encoding="iso-8859-1"): handler.ContentHandler.__init__(self) self._out = out self._ns_contexts = [{}] # contains uri -> prefix dicts @@ -95,10 +92,7 @@ self._encoding = encoding def _write(self, text): - if isinstance(text, str): - self._out.write(text) - else: - self._out.write(text.encode(self._encoding, _error_handling)) + self._out.write(text.encode(self._encoding, _error_handling)) def _qname(self, name): """Builds a qualified name from a (ns_url, localname) pair""" @@ -140,9 +134,9 @@ for prefix, uri in self._undeclared_ns_maps: if prefix: - self._out.write(' xmlns:%s="%s"' % (prefix, uri)) + self._write(' xmlns:%s="%s"' % (prefix, uri)) else: - self._out.write(' xmlns="%s"' % uri) + self._write(' xmlns="%s"' % uri) self._undeclared_ns_maps = [] for (name, value) in attrs.items():