Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
e3685fd5
Unverified
Kaydet (Commit)
e3685fd5
authored
Eki 28, 2018
tarafından
Raymond Hettinger
Kaydeden (comit)
GitHub
Eki 28, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-34160: Preserve user specified order of Element attributes (GH-10163)
üst
18d57b4d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
1 deletion
+30
-1
xml.etree.elementtree.rst
Doc/library/xml.etree.elementtree.rst
+8
-0
test_xml_etree.py
Lib/test/test_xml_etree.py
+20
-0
ElementTree.py
Lib/xml/etree/ElementTree.py
+1
-1
2018-10-27-21-11-42.bpo-34160.UzyPZf.rst
...S.d/next/Library/2018-10-27-21-11-42.bpo-34160.UzyPZf.rst
+1
-0
No files found.
Doc/library/xml.etree.elementtree.rst
Dosyayı görüntüle @
e3685fd5
...
...
@@ -489,6 +489,10 @@ Functions
*elem* is an element tree or an individual element.
.. versionchanged:: 3.8
The :func:`dump` function now preserves the attribute order specified
by the user.
.. function:: fromstring(text)
...
...
@@ -947,6 +951,10 @@ ElementTree Objects
.. versionadded:: 3.4
The *short_empty_elements* parameter.
.. versionchanged:: 3.8
The :meth:`write` method now preserves the attribute order specified
by the user.
This is the XML file that is going to be manipulated::
...
...
Lib/test/test_xml_etree.py
Dosyayı görüntüle @
e3685fd5
...
...
@@ -5,6 +5,7 @@
# For this purpose, the module-level "ET" symbol is temporarily
# monkey-patched when running the "test_xml_etree_c" test suite.
import
contextlib
import
copy
import
functools
import
html
...
...
@@ -1044,6 +1045,25 @@ class ElementTreeTest(unittest.TestCase):
method
=
'html'
)
self
.
assertEqual
(
serialized
,
expected
)
def
test_dump_attribute_order
(
self
):
# See BPO 34160
e
=
ET
.
Element
(
'cirriculum'
,
status
=
'public'
,
company
=
'example'
)
with
support
.
captured_stdout
()
as
stdout
:
ET
.
dump
(
e
)
self
.
assertEqual
(
stdout
.
getvalue
(),
'<cirriculum status="public" company="example" />
\n
'
)
def
test_tree_write_attribute_order
(
self
):
# See BPO 34160
root
=
ET
.
Element
(
'cirriculum'
,
status
=
'public'
,
company
=
'example'
)
tree
=
ET
.
ElementTree
(
root
)
f
=
io
.
BytesIO
()
with
contextlib
.
redirect_stdout
(
f
):
tree
.
write
(
f
,
encoding
=
'utf-8'
,
xml_declaration
=
True
)
self
.
assertEqual
(
f
.
getvalue
(),
b
"<?xml version='1.0' encoding='utf-8'?>
\n
"
b
'<cirriculum status="public" company="example" />'
)
class
XMLPullParserTest
(
unittest
.
TestCase
):
...
...
Lib/xml/etree/ElementTree.py
Dosyayı görüntüle @
e3685fd5
...
...
@@ -923,7 +923,7 @@ def _serialize_xml(write, elem, qnames, namespaces,
k
,
_escape_attrib
(
v
)
))
for
k
,
v
in
sorted
(
items
):
# lexical order
for
k
,
v
in
items
:
if
isinstance
(
k
,
QName
):
k
=
k
.
text
if
isinstance
(
v
,
QName
):
...
...
Misc/NEWS.d/next/Library/2018-10-27-21-11-42.bpo-34160.UzyPZf.rst
0 → 100644
Dosyayı görüntüle @
e3685fd5
ElementTree now preserves the attribute order specified by the user.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment