Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4269d010
Commit
4269d010
authored
May 29, 2012
by
Hynek Schlawack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#14835: Make plistlib output empty arrays & dicts like OS X
Patch by Sidney San Martín.
parent
9762a282
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
12 deletions
+28
-12
Lib/plistlib.py
Lib/plistlib.py
+18
-12
Lib/test/test_plistlib.py
Lib/test/test_plistlib.py
+6
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/plistlib.py
View file @
4269d010
...
...
@@ -237,20 +237,26 @@ class PlistWriter(DumbXMLWriter):
self
.
endElement
(
"data"
)
def
writeDict
(
self
,
d
):
self
.
beginElement
(
"dict"
)
items
=
sorted
(
d
.
items
())
for
key
,
value
in
items
:
if
not
isinstance
(
key
,
str
):
raise
TypeError
(
"keys must be strings"
)
self
.
simpleElement
(
"key"
,
key
)
self
.
writeValue
(
value
)
self
.
endElement
(
"dict"
)
if
d
:
self
.
beginElement
(
"dict"
)
items
=
sorted
(
d
.
items
())
for
key
,
value
in
items
:
if
not
isinstance
(
key
,
str
):
raise
TypeError
(
"keys must be strings"
)
self
.
simpleElement
(
"key"
,
key
)
self
.
writeValue
(
value
)
self
.
endElement
(
"dict"
)
else
:
self
.
simpleElement
(
"dict"
)
def
writeArray
(
self
,
array
):
self
.
beginElement
(
"array"
)
for
value
in
array
:
self
.
writeValue
(
value
)
self
.
endElement
(
"array"
)
if
array
:
self
.
beginElement
(
"array"
)
for
value
in
array
:
self
.
writeValue
(
value
)
self
.
endElement
(
"array"
)
else
:
self
.
simpleElement
(
"array"
)
class
_InternalDict
(
dict
):
...
...
Lib/test/test_plistlib.py
View file @
4269d010
...
...
@@ -55,6 +55,10 @@ TESTDATA = b"""<?xml version="1.0" encoding="UTF-8"?>
</array>
<key>aString</key>
<string>Doodah</string>
<key>anEmptyDict</key>
<dict/>
<key>anEmptyList</key>
<array/>
<key>anInt</key>
<integer>728</integer>
<key>nestedData</key>
...
...
@@ -112,6 +116,8 @@ class TestPlistlib(unittest.TestCase):
someMoreData
=
plistlib
.
Data
(
b"<lots of binary gunk>
\
0
\
1
\
2
\
3
"
*
10
),
nestedData
=
[
plistlib
.
Data
(
b"<lots of binary gunk>
\
0
\
1
\
2
\
3
"
*
10
)],
aDate
=
datetime
.
datetime
(
2004
,
10
,
26
,
10
,
33
,
33
),
anEmptyDict
=
dict
(),
anEmptyList
=
list
()
)
pl
[
'
\
xc5
benraa'
]
=
"That was a unicode key."
return
pl
...
...
Misc/ACKS
View file @
4269d010
...
...
@@ -662,6 +662,7 @@ Alex Martelli
Anthony Martin
Owen Martin
Sébastien Martini
Sidney San Martín
Roger Masse
Nick Mathewson
Simon Mathieu
...
...
Misc/NEWS
View file @
4269d010
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Alpha 4?
Core and Builtins
-----------------
- Issue #14835: Make plistlib output empty arrays & dicts like OS X.
Patch by Sidney San Martín.
- Issue #14930: Make memoryview objects weakrefable.
- Issue #14775: Fix a potential quadratic dict build-up due to the garbage
...
...
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