[issue36407] xml.dom.minidom wrong indentation writing for CDATA section

2019-03-27 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36407] xml.dom.minidom wrong indentation writing for CDATA section

2019-03-27 Thread Stefan Behnel


Stefan Behnel  added the comment:

I don't think this should be backported. Pretty-printing is not a production 
relevant feature, more of a "debugging, diffing and help users see what they 
get" kind of feature. It's good to have it fixed for the future, but we 
shouldn't bother users with it during a point release.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36407] xml.dom.minidom wrong indentation writing for CDATA section

2019-03-27 Thread miss-islington


Change by miss-islington :


--
pull_requests: +12522

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36407] xml.dom.minidom wrong indentation writing for CDATA section

2019-03-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Should we backport this change? I am not sure.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36407] xml.dom.minidom wrong indentation writing for CDATA section

2019-03-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 384b81d923addd52125e94470b11d2574ca266a9 by Serhiy Storchaka 
(Vladimir Surjaninov) in branch 'master':
bpo-36407: Fix writing indentations of CDATA section (xml.dom.minidom). 
(GH-12514)
https://github.com/python/cpython/commit/384b81d923addd52125e94470b11d2574ca266a9


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36407] xml.dom.minidom wrong indentation writing for CDATA section

2019-03-23 Thread Stefan Behnel


Stefan Behnel  added the comment:

Yes, this case is incorrect. Pretty printing should not change character 
content inside of a simple tag.

The PR looks good to me.

--
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36407] xml.dom.minidom wrong indentation writing for CDATA section

2019-03-23 Thread Vladimir Surjaninov


Change by Vladimir Surjaninov :


--
keywords: +patch
pull_requests: +12465
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36407] xml.dom.minidom wrong indentation writing for CDATA section

2019-03-23 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +eli.bendersky, scoder, serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36407] xml.dom.minidom wrong indentation writing for CDATA section

2019-03-23 Thread Vladimir Surjaninov

New submission from Vladimir Surjaninov :

If we are writing xml with CDATA section and leaving non-empty indentation and 
new-line parameters, a parent node of the section will contain useless 
indentation, that will be parsed as a text.

Example:
>>>doc = minidom.Document()
>>>root = doc.createElement('root')
>>>doc.appendChild(root)
>>>node = doc.createElement('node')
>>>root.appendChild(node)
>>>data = doc.createCDATASection('')
>>>node.appendChild(data)
>>>print(doc.toprettyxml(indent=‘  ‘ * 4)






If we try to parse this output doc, we won’t get CDATA value correctly.

Following code returns a string that contains only indentation characters:
>>>doc = minidom.parseString(xml_text)
>>>doc.getElementsByTagName('node')[0].firstChild.nodeValue

Returns a string with CDATA value and indentation characters:
>>>doc.getElementsByTagName('node')[0].firstChild.wholeText


But we have a workaround:
>>>data.nodeType = data.TEXT_NODE
…
>>>print(doc.toprettyxml(indent=‘  ‘ * 4)





It will be parsed correctly:
>>>doc.getElementsByTagName('node')[0].firstChild.nodeValue


But I think it will be better if we fix the writing function, which would set 
this as default behavior.

--
components: XML
messages: 338681
nosy: vsurjaninov
priority: normal
severity: normal
status: open
title: xml.dom.minidom wrong indentation writing for CDATA section
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com