cpython: 1c01571ce0f4 (original) (raw)

Mercurial > cpython

changeset 83737:1c01571ce0f4 3.2

Issue #17915: Fix interoperability of xml.sax with file objects returned by codecs.open(). [#17915]

Georg Brandl georg@python.org
date Sun, 12 May 2013 11:41:12 +0200
parents 854ba6f414a8
children cef745775b65 19a5fbb924b1
files Lib/test/test_sax.py Lib/xml/sax/saxutils.py Misc/NEWS
diffstat 3 files changed, 39 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_sax.py 31 Lib/xml/sax/saxutils.py 5 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -15,6 +15,7 @@ from xml.sax.expatreader import create_p from xml.sax.handler import feature_namespaces from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl from io import BytesIO, StringIO +import codecs import os.path import shutil from test import support @@ -538,6 +539,34 @@ class WriterXmlgenTest(BytesXmlgenTest): def getvalue(self): return b''.join(self) +class StreamWriterXmlgenTest(XmlgenTest, unittest.TestCase):

+

+ +class StreamReaderWriterXmlgenTest(XmlgenTest, unittest.TestCase):

+

+

+

start = b'\n' @@ -946,6 +975,8 @@ def test_main(): StringXmlgenTest, BytesXmlgenTest, WriterXmlgenTest,

--- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -5,6 +5,7 @@ convenience of application and driver wr 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

+ # wrap a binary writer with TextIOWrapper if isinstance(out, io.RawIOBase): # Keep the original file open when the TextIOWrapper is

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -20,6 +20,9 @@ Library