diff options
author | Georg Brandl <georg@python.org> | 2013-05-12 11:41:12 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2013-05-12 11:41:12 +0200 |
commit | c502df4e3e00ec2481f1f0a80af37c9d822787b3 (patch) | |
tree | 71315fc75d9fa55815137fcbf93fd408bdec89ce /Lib/xml/sax | |
parent | Issue #1159051: Back out a fix for handling corrupted gzip files that (diff) | |
download | cpython-c502df4e3e00ec2481f1f0a80af37c9d822787b3.tar.gz cpython-c502df4e3e00ec2481f1f0a80af37c9d822787b3.tar.bz2 cpython-c502df4e3e00ec2481f1f0a80af37c9d822787b3.zip |
Issue #17915: Fix interoperability of xml.sax with file objects returned by
codecs.open().
Diffstat (limited to 'Lib/xml/sax')
-rw-r--r-- | Lib/xml/sax/saxutils.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py index a62183a8483..0798ecd70d1 100644 --- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -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 |