[ python-Bugs-1262320 ] minidom.py alternate newl support is broken

SourceForge.net noreply at sourceforge.net
Fri Aug 26 00:14:29 CEST 2005


Bugs item #1262320, was opened at 2005-08-17 19:11
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1262320&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: XML
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: John Whitley (jwhitley)
>Assigned to: Reinhold Birkenfeld (birkenfeld)
Summary: minidom.py alternate newl support is broken

Initial Comment:
In minidom.py, class Document and a few other nodes
have hardcoded newlines ('\n') remaining, causing the
"newl" parameter to potentially produce a file with
mixed line endings, e.g. if newl is set to Windows line
endings ("\r\n" ).
A diff follows which fixes all instances of the problem
of which I'm aware.

*** /usr/lib/python2.4/xml/dom/minidom.py.orig	Tue Aug
16 17:38:40 2005
--- /usr/lib/python2.4/xml/dom/minidom.py.new	Tue Aug
16 17:38:40 2005
***************
*** 1286,1292 ****
              writer.write(" [")
              writer.write(self.internalSubset)
              writer.write("]")
!         writer.write(">\n")
  
  class Entity(Identified, Node):
      attributes = None
--- 1286,1292 ----
              writer.write(" [")
              writer.write(self.internalSubset)
              writer.write("]")
!         writer.write(">%s" % newl)
  
  class Entity(Identified, Node):
      attributes = None
***************
*** 1739,1747 ****
      def writexml(self, writer, indent="",
addindent="", newl="",
                   encoding = None):
          if encoding is None:
!             writer.write('<?xml version="1.0" ?>\n')
          else:
!             writer.write('<?xml version="1.0"
encoding="%s"?>\n' % encoding)
          for node in self.childNodes:
              node.writexml(writer, indent, addindent,
newl)
  
--- 1739,1747 ----
      def writexml(self, writer, indent="",
addindent="", newl="",
                   encoding = None):
          if encoding is None:
!             writer.write('<?xml version="1.0" ?>%s' %
newl)
          else:
!             writer.write('<?xml version="1.0"
encoding="%s"?>%s' % (encoding,newl))
          for node in self.childNodes:
              node.writexml(writer, indent, addindent,
newl)
  


----------------------------------------------------------------------

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-08-26 00:14

Message:
Logged In: YES 
user_id=1188172

Thanks for the report, fixed in Lib/xml/dom/minidom.py
r1.53, 1.52.4.1.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1262320&group_id=5470


More information about the Python-bugs-list mailing list