From 1b5f58d1670852871a9865a7b67e14626561f8d1 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 25 Jul 2014 10:26:36 -0700 Subject: [PATCH] Issue #21990: Cleanup unnecessary inner class definition in saxutils. --- Lib/xml/sax/saxutils.py | 13 ++++++++----- Misc/NEWS | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py index 1abcd9a0c4..1b89e31aed 100644 --- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -98,14 +98,17 @@ def _gettextwriter(out, encoding): except AttributeError: pass # wrap a binary writer with TextIOWrapper - class UnbufferedTextIOWrapper(io.TextIOWrapper): - def write(self, s): - super(UnbufferedTextIOWrapper, self).write(s) - self.flush() - return UnbufferedTextIOWrapper(buffer, encoding=encoding, + return _UnbufferedTextIOWrapper(buffer, encoding=encoding, errors='xmlcharrefreplace', newline='\n') + +class _UnbufferedTextIOWrapper(io.TextIOWrapper): + def write(self, s): + super(_UnbufferedTextIOWrapper, self).write(s) + self.flush() + + class XMLGenerator(handler.ContentHandler): def __init__(self, out=None, encoding="iso-8859-1"): diff --git a/Misc/NEWS b/Misc/NEWS index 4cfa3c2af2..4702dfe7bb 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -17,6 +17,9 @@ Library socket.error() exceptions with blocking I/O errors: EAGAIN, EALREADY, EINPROGRESS, or EWOULDBLOCK. +- Issue #21990: Clean-up unnecessary and slow inner class definition in + saxutils (Contributed by Alex Gaynor). + - Issue #1730136: Fix the comparison between a tkFont.Font and an object of another kind. -- 2.50.1