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
914bd3fa
Commit
914bd3fa
authored
Jul 23, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #21888: plistlib's load() and loads() now work if the fmt parameter is
specified.
parent
cfab2b39
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
Lib/plistlib.py
Lib/plistlib.py
+3
-5
Lib/test/test_plistlib.py
Lib/test/test_plistlib.py
+5
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/plistlib.py
View file @
914bd3fa
...
...
@@ -984,18 +984,16 @@ def load(fp, *, fmt=None, use_builtin_types=True, dict_type=dict):
fp
.
seek
(
0
)
for
info
in
_FORMATS
.
values
():
if
info
[
'detect'
](
header
):
p
=
info
[
'parser'
](
use_builtin_types
=
use_builtin_types
,
dict_type
=
dict_type
,
)
P
=
info
[
'parser'
]
break
else
:
raise
InvalidFileException
()
else
:
p
=
_FORMATS
[
fmt
][
'parser'
](
use_builtin_types
=
use_builtin_types
)
P
=
_FORMATS
[
fmt
][
'parser'
]
p
=
P
(
use_builtin_types
=
use_builtin_types
,
dict_type
=
dict_type
)
return
p
.
parse
(
fp
)
...
...
Lib/test/test_plistlib.py
View file @
914bd3fa
...
...
@@ -207,6 +207,9 @@ class TestPlistlib(unittest.TestCase):
for
fmt
in
ALL_FORMATS
:
with
self
.
subTest
(
fmt
=
fmt
):
pl
=
self
.
_create
(
fmt
=
fmt
)
pl2
=
plistlib
.
loads
(
TESTDATA
[
fmt
],
fmt
=
fmt
)
self
.
assertEqual
(
dict
(
pl
),
dict
(
pl2
),
"generated data was not identical to Apple's output"
)
pl2
=
plistlib
.
loads
(
TESTDATA
[
fmt
])
self
.
assertEqual
(
dict
(
pl
),
dict
(
pl2
),
"generated data was not identical to Apple's output"
)
...
...
@@ -217,6 +220,8 @@ class TestPlistlib(unittest.TestCase):
b
=
BytesIO
()
pl
=
self
.
_create
(
fmt
=
fmt
)
plistlib
.
dump
(
pl
,
b
,
fmt
=
fmt
)
pl2
=
plistlib
.
load
(
BytesIO
(
b
.
getvalue
()),
fmt
=
fmt
)
self
.
assertEqual
(
dict
(
pl
),
dict
(
pl2
))
pl2
=
plistlib
.
load
(
BytesIO
(
b
.
getvalue
()))
self
.
assertEqual
(
dict
(
pl
),
dict
(
pl2
))
...
...
Misc/NEWS
View file @
914bd3fa
...
...
@@ -27,6 +27,9 @@ Core and Builtins
Library
-------
- Issue #21888: plistlib'
s
load
()
and
loads
()
now
work
if
the
fmt
parameter
is
specified
.
-
Issue
#
21044
:
tarfile
.
open
()
now
handles
fileobj
with
an
integer
'name'
attribute
.
Based
on
patch
by
Antoine
Pietri
.
...
...
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