]> granicus.if.org Git - python/commitdiff
Issue #21990: Cleanup unnecessary inner class definition in saxutils.
authorRaymond Hettinger <python@rcn.com>
Fri, 25 Jul 2014 17:26:36 +0000 (10:26 -0700)
committerRaymond Hettinger <python@rcn.com>
Fri, 25 Jul 2014 17:26:36 +0000 (10:26 -0700)
Lib/xml/sax/saxutils.py
Misc/NEWS

index 1abcd9a0c4aa8bf03359d0f00ea0b84489d235b2..1b89e31aed8f3a6d74a11e25c6ddf59d65704703 100644 (file)
@@ -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"):
index 4cfa3c2af21417d43eee7563778d172434468e2a..4702dfe7bb5731f10d2764782023be07051ea4cf 100644 (file)
--- 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.