[pypy-commit] pypy default: Move the class declaration outside the function. There is no

arigo noreply at buildbot.pypy.org
Wed Jul 16 16:16:53 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r72455:ace3f0199007
Date: 2014-07-16 16:16 +0200
http://bitbucket.org/pypy/pypy/changeset/ace3f0199007/

Log:	Move the class declaration outside the function. There is no reason
	to have a local class: it doesn't depend on anything. This fixes
	issue #1818.

diff --git a/lib-python/2.7/xml/sax/saxutils.py b/lib-python/2.7/xml/sax/saxutils.py
--- a/lib-python/2.7/xml/sax/saxutils.py
+++ b/lib-python/2.7/xml/sax/saxutils.py
@@ -98,13 +98,14 @@
         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')
+# PyPy: moved this class outside the function above
+class _UnbufferedTextIOWrapper(io.TextIOWrapper):
+    def write(self, s):
+        super(_UnbufferedTextIOWrapper, self).write(s)
+        self.flush()
 
 class XMLGenerator(handler.ContentHandler):
 


More information about the pypy-commit mailing list