[Lxml-checkins] r46697 - lxml/trunk/src/lxml

scoder at codespeak.net scoder at codespeak.net
Mon Sep 17 18:04:20 CEST 2007


Author: scoder
Date: Mon Sep 17 18:04:20 2007
New Revision: 46697

Modified:
   lxml/trunk/src/lxml/serializer.pxi
Log:
cleanup in text serialiser

Modified: lxml/trunk/src/lxml/serializer.pxi
==============================================================================
--- lxml/trunk/src/lxml/serializer.pxi	(original)
+++ lxml/trunk/src/lxml/serializer.pxi	Mon Sep 17 18:04:20 2007
@@ -26,17 +26,13 @@
     if c_text is NULL:
         python.PyErr_NoMemory()
 
-    try:
-        if _hasTail(c_node):
-            tail = _collectText(c_node.next)
-            if tail:
-                text = c_text + tail
-            else:
-                text = c_text
-        else:
-            text = c_text
-    finally:
-        tree.xmlFree(c_text)
+    text = c_text
+    tree.xmlFree(c_text)
+
+    if _hasTail(c_node):
+        tail = _collectText(c_node.next)
+        if tail:
+            text = text + tail
 
     if encoding is None:
         return text
@@ -326,7 +322,8 @@
     c_method = _findOutputMethod(method)
     if c_method == OUTPUT_METHOD_TEXT:
         if _isString(f):
-            f = open(f, 'wb')
+            filename8 = _encodeFilename(f)
+            f = open(filename8, 'wb')
             f.write(_textToString(element._c_node, encoding))
             f.close()
         else:


More information about the lxml-checkins mailing list