summaryrefslogtreecommitdiff
path: root/Lib/xml
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2013-05-12 11:41:12 +0200
committerGeorg Brandl <georg@python.org>2013-05-12 11:41:12 +0200
commitab6a69347e27266a3ad1e2350e682448ecbaee9a (patch)
tree5c43d775bdc1777c77b6a9290065705553e3892d /Lib/xml
parent4bb59c5ebc248530d10adab930b0a03172eff319 (diff)
downloadcpython-ab6a69347e27266a3ad1e2350e682448ecbaee9a.tar.gz
Issue #17915: Fix interoperability of xml.sax with file objects returned by
codecs.open().
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/sax/saxutils.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py
index a62183a848..0798ecd70d 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