Reputation: 515
I'm using plistlib to create and update a simple plist file in OS X. A tester in Norway is getting an error from plistlib:
File "../axeomatic2/normal/build/pyi.darwin/aomDSP/out03-PYZ.pyz/plistlib", line 406, in parse
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 8
Looking at the plist file that was generated on his system, I see fields like this interspersed with the expected entries:
NSTableView Sort Ordering Array
...
NSTableView Hidden Columns Array
...
NSTableView Columns Array
...
NSNavLastRootDirectory Array
If I give him a plist from my system it works fine, but any time the program decides it needs to create one from scratch it gets an error.
I thought perhaps it was an encoding problem, but we're both on OS X 10.7 and both using the OS X version of UTF-8.
Any ideas as to what might be happening, or how I might troubleshoot this remotely?
Upvotes: 3
Views: 1131
Reputation: 412
Binary plist support has been added to plistlib
since python 3.4.
https://docs.python.org/3.4/library/plistlib.html
Upvotes: 1
Reputation: 5875
There's actually two categories of plist
format. One is actually simple XML file (which plistlib
knows how to parse with expat
), the other one is binary property list
.
Unfortunately they both share the same suffix .plist
, and all the tools from Apple treat them transparently (e.g. you don't know if you are working with an XML plist or a binary plist, using tools like defaults
)
Like @northtree said, the biplist
package is the right tool to read/write the binary plist file.
UPDATE:
You can also use plutil(1)
that comes with OSX to convert any plist
file back to XML format, and then processed by plistlib
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/plutil.1.html
Upvotes: 0