This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: plistlib and xml.parsers.expat python3 problems with strings and bytes
Type: crash Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Ulrich.Dorsch, ronaldoussoren, serhiy.storchaka
Priority: normal Keywords:

Created on 2015-02-12 14:31 by Ulrich.Dorsch, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg235828 - (view) Author: Ulrich Dorsch (Ulrich.Dorsch) Date: 2015-02-12 14:31
TypeError: startswith first arg must be str or a tuple of str, not bytes

In line 558 of plistlib.py at the beginnging of "def _is_fmt_xml(header)" is the problem, caused by the use of the byte arguments defined in line 555 (prefixes = (b'<?xml', b'<plist')).

Similar Problem in line 572:
header.startswith(bom). bom is of type bytes.

FIX: change the definition to:
line 555: prefixes = ('<?xml', '<plist')
line 572: header.startswith(str(bom))

Remaining problem is:
TypeError: read() did not return a bytes object (type=str)

This occurs in the parser object generated by ParserCreate() from xml.parsers.expat

I stopped there with tracing / resolving the problem.
msg235837 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-02-12 15:33
All correct. plistlib.load() requires binary file object as documented [1].

[1] https://docs.python.org/3/library/plistlib.html#plistlib.load
History
Date User Action Args
2022-04-11 14:58:12adminsetgithub: 67642
2015-02-12 15:33:08serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka, ronaldoussoren
messages: + msg235837

resolution: not a bug
2015-02-12 14:31:58Ulrich.Dorschcreate