[Python-checkins] Clarify that plistlib's load and dump functions take a binary file object (GH-9825)

Miss Islington (bot) webhook-mailer at python.org
Sun Jul 14 05:23:42 EDT 2019


https://github.com/python/cpython/commit/5631e381a6fbc471896b5562d542be0a6befa797
commit: 5631e381a6fbc471896b5562d542be0a6befa797
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-07-14T02:23:38-07:00
summary:

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.htmlGH-plistlib.load
https://docs.python.org/3/library/plistlib.htmlGH-plistlib.dump
(cherry picked from commit 0d4f4352efecf1b044c88e234e71774fe04b7d6c)

Co-authored-by: Collin Styles <collingstyles at gmail.com>

files:
M Lib/plistlib.py

diff --git a/Lib/plistlib.py b/Lib/plistlib.py
index 21ebec3f0045..33b79a133b0a 100644
--- a/Lib/plistlib.py
+++ b/Lib/plistlib.py
@@ -929,7 +929,7 @@ def _is_fmt_binary(header):
 
 
 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).
     """
     if fmt is None:
@@ -960,8 +960,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):
-    """Write 'value' to a .plist file. 'fp' should be a (writable)
-    file object.
+    """Write 'value' to a .plist file. 'fp' should be a writable,
+    binary file object.
     """
     if fmt not in _FORMATS:
         raise ValueError("Unsupported format: %r"%(fmt,))



More information about the Python-checkins mailing list