|
From: <am...@us...> - 2010-06-25 14:22:15
|
Revision: 7070
http://jython.svn.sourceforge.net/jython/?rev=7070&view=rev
Author: amak
Date: 2010-06-25 14:22:08 +0000 (Fri, 25 Jun 2010)
Log Message:
-----------
Fix for bug 1614: minidom chunks the character input on multi-line values
Modified Paths:
--------------
trunk/jython/Lib/test/test_minidom.py
trunk/jython/Lib/xml/dom/minidom.py
trunk/jython/NEWS
Modified: trunk/jython/Lib/test/test_minidom.py
===================================================================
--- trunk/jython/Lib/test/test_minidom.py 2010-06-25 13:16:13 UTC (rev 7069)
+++ trunk/jython/Lib/test/test_minidom.py 2010-06-25 14:22:08 UTC (rev 7070)
@@ -523,6 +523,29 @@
"testNormalize -- single empty node removed")
doc.unlink()
+def testNormalizedAfterLoad():
+ """
+ Introduced this test on jython because
+ 1. Cpython guarantees, by the use of xml.dom.expatbuilder,
+ that all text nodes are normalized after loading.
+ 2. Jython has no expat, and thus uses xml.dom.pulldom.parse
+ (which uses any java SAX2 compliant parser), and which makes
+ no guarantees about text node normalization.
+ Thus we have to check if text nodes are normalized after a parse.
+ See this bug for further information
+ minidom chunks the character input on multi-line values
+ http://bugs.jython.org/issue1614
+ """
+ num_lines = 2
+ # Up to 16K lines should be enough to guarantee failure without normalization
+ while num_lines <= 2**14:
+ doc_content = "\n".join( ("Line %d" % i for i in xrange(num_lines)) )
+ doc_text = "<document>%s</document>" % doc_content
+ dom = parseString(doc_text)
+ node_content = dom.getElementsByTagName("document")[0].childNodes[0].nodeValue
+ confirm(node_content == doc_content, "testNormalizedAfterLoad")
+ num_lines *= 2
+
def testSiblings():
doc = parseString("<doc><?pi?>text?<elm/></doc>")
root = doc.documentElement
Modified: trunk/jython/Lib/xml/dom/minidom.py
===================================================================
--- trunk/jython/Lib/xml/dom/minidom.py 2010-06-25 13:16:13 UTC (rev 7069)
+++ trunk/jython/Lib/xml/dom/minidom.py 2010-06-25 14:22:08 UTC (rev 7070)
@@ -1908,6 +1908,7 @@
toktype, rootNode = events.getEvent()
events.expandNode(rootNode)
events.clear()
+ rootNode.normalize()
return rootNode
def parse(file, parser=None, bufsize=None):
Modified: trunk/jython/NEWS
===================================================================
--- trunk/jython/NEWS 2010-06-25 13:16:13 UTC (rev 7069)
+++ trunk/jython/NEWS 2010-06-25 14:22:08 UTC (rev 7070)
@@ -2,6 +2,7 @@
Jython 2.5.2a1
Bugs Fixed
+ - [ 1614 ] minidom chunks the character input on multi-line values
- [ 1615 ] Can't invoke Java method that takes a variable number of arguments with zero arguments
- [ 1605 ] float preference over PyComplex as arg to __call__ breaks logic
- [ 1586 ] weakref reference count leak when kwargs are used
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|