This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: minidom.py alternate newl support is broken
Type: Stage:
Components: XML Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, georg.brandl, jwhitley
Priority: normal Keywords:

Created on 2005-08-17 17:11 by jwhitley, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg26071 - (view) Author: John Whitley (jwhitley) Date: 2005-08-17 17:11
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)
  
msg26072 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-08-25 22:14
Logged In: YES 
user_id=1188172

Thanks for the report, fixed in Lib/xml/dom/minidom.py
r1.53, 1.52.4.1.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42287
2005-08-17 17:11:19jwhitleycreate