classification
Title: plistlib has no graceful way of handing None values
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: Behdad.Esfahbod, Matt.Hansen, bobveznat, jvr, ned.deily, ronaldoussoren, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2011-02-02 19:10 by bobveznat, last changed 2015-04-23 18:28 by Behdad.Esfahbod.

Files
File name Uploaded Description Edit
plistlib.patch bobveznat, 2011-02-02 19:10 Patch adding ignoreNone parameter
Messages (4)
msg127750 - (view) Author: Bob Van Zant (bobveznat) Date: 2011-02-02 19:10
The Apple plist format does not support None or Null values in its output. A Null value in plist is denoted by the absence of the key in the data structure.

The python plist writer generates a TypeError when a None value is encoded. This issue is to track dealing with None values.

A suggestion is to have a flag on the various plist write functions and methods that will allow ignoring None values.

No changes are required to the plist reader.
msg189911 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-05-24 14:07
At first I didn't like the proposal, but when I looked at the JSON module I noticed it has similar functionality for ignoring keys that cannot be represented in a JSON file.

I'll look into this after merging #14455.

The JSON library has two other options that might be useful for the plistlib library: sort_keys (sort the keys in the serialization of of dicts) and default(obj), which is a function for transforming values that cannot be represented natively.
msg228560 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-10-05 11:56
Note that binary plist format supports None.
msg241873 - (view) Author: Behdad Esfahbod (Behdad.Esfahbod) Date: 2015-04-23 18:28
plistlib's internal implementation already supports sort_keys and skipkeys, those just are not wired to load() and loads().
History
Date User Action Args
2015-04-23 18:28:08Behdad.Esfahbodsetnosy: + Behdad.Esfahbod
messages: + msg241873
2014-12-03 19:40:44Matt.Hansensetnosy: + Matt.Hansen
2014-10-05 11:56:41serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg228560
2013-05-24 14:07:39ronaldoussorensetversions: + Python 3.4, - Python 2.7
nosy: + ned.deily

messages: + msg189911

assignee: ronaldoussoren
2011-02-04 17:43:31eric.araujosetnosy: + jvr, ronaldoussoren
2011-02-02 19:10:51bobveznatcreate