Clarify that plistlib's load and dump functions take a binary file object (GH-9825)
The documentation says that the fp parameter to plistlib.load "should be a readable and binary file object" but the docstring only mentions that it should be readable. Similarly, plistlib.dump's docstring only mentions "writable". This commit clarifies that fp should also be binary. https://docs.python.org/3/library/plistlib.html#plistlib.load https://docs.python.org/3/library/plistlib.html#plistlib.dump
This commit is contained in:
parent
52c8c09087
commit
0d4f4352ef
|
@ -971,7 +971,7 @@ _FORMATS={
|
||||||
|
|
||||||
|
|
||||||
def load(fp, *, fmt=None, use_builtin_types=True, dict_type=dict):
|
def load(fp, *, fmt=None, use_builtin_types=True, dict_type=dict):
|
||||||
"""Read a .plist file. 'fp' should be (readable) file object.
|
"""Read a .plist file. 'fp' should be a readable and binary file object.
|
||||||
Return the unpacked root object (which usually is a dictionary).
|
Return the unpacked root object (which usually is a dictionary).
|
||||||
"""
|
"""
|
||||||
if fmt is None:
|
if fmt is None:
|
||||||
|
@ -1002,8 +1002,8 @@ def loads(value, *, fmt=None, use_builtin_types=True, dict_type=dict):
|
||||||
|
|
||||||
|
|
||||||
def dump(value, fp, *, fmt=FMT_XML, sort_keys=True, skipkeys=False):
|
def dump(value, fp, *, fmt=FMT_XML, sort_keys=True, skipkeys=False):
|
||||||
"""Write 'value' to a .plist file. 'fp' should be a (writable)
|
"""Write 'value' to a .plist file. 'fp' should be a writable,
|
||||||
file object.
|
binary file object.
|
||||||
"""
|
"""
|
||||||
if fmt not in _FORMATS:
|
if fmt not in _FORMATS:
|
||||||
raise ValueError("Unsupported format: %r"%(fmt,))
|
raise ValueError("Unsupported format: %r"%(fmt,))
|
||||||
|
|
Loading…
Reference in New Issue