Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue36227

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Add default_namespace argument to xml.etree.ElementTree.tostring()
Type:enhancementStage:resolved
Components:Library (Lib), XMLVersions:Python 3.8
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: Bernt.Røskar.Brenna, eli.bendersky, scoder, serhiy.storchaka
Priority:normalKeywords:patch

Created on2019-03-07 18:57 byBernt.Røskar.Brenna, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 12225mergedBernt.Røskar.Brenna,2019-03-07 19:10
Messages (9)
msg337428 -(view)Author: Bernt Røskar Brenna (Bernt.Røskar.Brenna)*Date: 2019-03-07 18:57
default_namespace is often used when serializing ET elements. tostring() is mainly a wrapper around ElementTree.write(), and it is therefore natural that it mirrors write's argument. tostring() already passes encoding, method and short_empty_elements to write.
msg337455 -(view)Author: Stefan Behnel (scoder)*(Python committer)Date: 2019-03-08 08:37
The feature seems reasonable to me and the patch looks good.
msg337456 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2019-03-08 08:50
See alsoissue31256.I do not know what is better: make tostring() to accept all options of write(), or keep it simpler. What strategy lxml supports?
msg337458 -(view)Author: Stefan Behnel (scoder)*(Python committer)Date: 2019-03-08 08:58
lxml does not support the "default_namespace" option specifically (because its tree model preserves namespace prefixes), but it generally makes all (justifiable) serialisation options available to both tostring() and ET.write().I think the same should apply to ElementTree. Both the "default_namespace" and "doctype" options seem useful regardless of the serialisation target.
msg337460 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2019-03-08 09:51
Okay. Bernt, do you mind to add also the xml_declaration option inPR 12225 or create a separate PR forissue31256?
msg337473 -(view)Author: Bernt Røskar Brenna (Bernt.Røskar.Brenna)*Date: 2019-03-08 13:28
I will add xml_declaration and push to the existing PR.
msg337478 -(view)Author: Bernt Røskar Brenna (Bernt.Røskar.Brenna)*Date: 2019-03-08 14:02
I pushed changes to the PR. I also added xml_declaration and default_namespace to the tostringlist() method.
msg340190 -(view)Author: Stefan Behnel (scoder)*(Python committer)Date: 2019-04-14 08:07
New changesetffca16e25a70fd44a87b13b379b5ec0c7a11e926 by Stefan Behnel (Bernt Røskar Brenna) in branch 'master':bpo-36227: ElementTree.tostring() default_namespace and xml_declaration arguments (GH-12225)https://github.com/python/cpython/commit/ffca16e25a70fd44a87b13b379b5ec0c7a11e926
msg340193 -(view)Author: Stefan Behnel (scoder)*(Python committer)Date: 2019-04-14 08:16
Thank you for you contribution.
History
DateUserActionArgs
2022-04-11 14:59:12adminsetgithub: 80408
2019-04-14 08:16:04scodersetstatus: open -> closed
messages: +msg340193

components: + XML
resolution: fixed
stage: patch review -> resolved
2019-04-14 08:07:16scodersetmessages: +msg340190
2019-03-08 14:02:12Bernt.Røskar.Brennasetmessages: +msg337478
2019-03-08 13:28:32Bernt.Røskar.Brennasetmessages: +msg337473
2019-03-08 09:51:18serhiy.storchakasetmessages: +msg337460
2019-03-08 08:58:56scodersetmessages: +msg337458
2019-03-08 08:50:51serhiy.storchakasetmessages: +msg337456
2019-03-08 08:37:57scodersetmessages: +msg337455
2019-03-08 03:06:25xtreaksetnosy: +scoder,eli.bendersky,serhiy.storchaka
2019-03-07 19:10:22Bernt.Røskar.Brennasetkeywords: +patch
stage: patch review
pull_requests: +pull_request12215
2019-03-07 18:57:14Bernt.Røskar.Brennacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp