Issue #17915: Fix interoperability of xml.sax with file objects returned by

codecs.open().
This commit is contained in:
Georg Brandl 2013-05-12 11:41:12 +02:00
parent 93b061bc3e
commit c502df4e3e
3 changed files with 39 additions and 0 deletions

View file

@ -5,6 +5,7 @@ convenience of application and driver writers.
import os, urllib.parse, urllib.request
import io
import codecs
from . import handler
from . import xmlreader
@ -77,6 +78,10 @@ def _gettextwriter(out, encoding):
# use a text writer as is
return out
if isinstance(out, (codecs.StreamWriter, codecs.StreamReaderWriter)):
# use a codecs stream writer as is
return out
# wrap a binary writer with TextIOWrapper
if isinstance(out, io.RawIOBase):
# Keep the original file open when the TextIOWrapper is