electronut / pp

Code for book Python Playground by Mahesh Venkitachalam (No Starch Press, USA)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeprecationWarning: The readPlist function is deprecated

renato0584 opened this issue · comments

The code presents the following error:

anatomyPlaylist.py:16: DeprecationWarning: The readPlist function is deprecated, use load() instead
plist = plistlib.readPlist(fileName)
Traceback (most recent call last):
File "anatomyPlaylist.py", line 162, in
main()
File "anatomyPlaylist.py", line 149, in main
findCommonTracks(args.plFiles)
File "anatomyPlaylist.py", line 16, in findCommonTracks
plist = plistlib.readPlist(fileName)
File "C:\Users\ext.renatoss1\AppData\Local\Programs\Python\Python37-32\lib\plistlib.py", line 100, in readPlist
return load(fp, fmt=None, use_builtin_types=False)
File "C:\Users\ext.renatoss1\AppData\Local\Programs\Python\Python37-32\lib\plistlib.py", line 944, in load
raise InvalidFileException()
plistlib.InvalidFileException: Invalid file

I've changed the line:

plist = plistlib.readPlist(fileName)

to

plist = np.load(fileName)

but, the error changed to:

Traceback (most recent call last):
File "C:\Users\ext.renatoss1\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\lib\npyio.py", line 440, in load
return pickle.load(fid, **pickle_kwargs)_pickle.UnpicklingError: invalid load key, '\x0a'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "anatomyPlaylist.py", line 162, in
main()
File "anatomyPlaylist.py", line 149, in main
findCommonTracks(args.plFiles)
File "anatomyPlaylist.py", line 16, in findCommonTracks
plist = np.load(fileName)
File "C:\Users\ext.renatoss1\AppData\Local\Programs\Python\Python37-32\lib\sit
e-packages\numpy\lib\npyio.py", line 443, in load
"Failed to interpret file %s as a pickle" % repr(file))
OSError: Failed to interpret file 'maya.xml' as a pickle

Of course there is some other modification to make, but I can't figure it out yet.

Advices?

Thanks and sorry for my poor english.

with open(filename,'rb') as fp:
pl=plistlib.load(fp)

Submitted PR #22 to accommodate this.