urschrei / pyzotero

Pyzotero: a Python client for the Zotero API
https://pyzotero.readthedocs.org
Other
908 stars 99 forks source link

feedparser UnicodeDecodeError after 1.4.8 #107

Closed Eothred closed 5 years ago

Eothred commented 5 years ago

General

Platform: (Manjaro) Linux Python version: 3.7.4 Pyzotero version: 1.4.8

Problem description

I see that 1.4.8 removed a workaround for a feedparser issue, but I don't see an upstream fix? Maybe I am missing something. Running the same code with 1.4.7 works fine.

A minimal settings.py that triggers the bug for me looks like

titlestring = "Title"
group_collection(1048946, collection='ZWVSAZGP')
sort_criteria = ['-date']

If possible, paste the full traceback in a code block below, and fill in the summary

Traceback ``` ./zot.py --settings settings-dbg.py ./zot.py:303: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp Loaded settings from /home/yngvelevinsen/Programming/bp-bibliography/settings-dbg.py. Traceback (most recent call last): File "/usr/lib/python3.7/base64.py", line 510, in _input_type_check m = memoryview(s) TypeError: memoryview: a bytes-like object is required, not 'str' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/yngvelevinsen/.local/lib/python3.7/site-packages/feedparser.py", line 878, in pop output = _base64decode(output) File "/usr/lib/python3.7/base64.py", line 545, in decodebytes _input_type_check(s) File "/usr/lib/python3.7/base64.py", line 513, in _input_type_check raise TypeError(msg) from err TypeError: expected bytes-like object, not str During handling of the above exception, another exception occurred: Traceback (most recent call last): File "./zot.py", line 2409, in generate_html(include_collections, item_filters) File "./zot.py", line 2334, in generate_html all_items, item_ids = retrieve_all_items(sortedkeys) File "./zot.py", line 2074, in retrieve_all_items i2 = list(e.db.retrieve_data(key)) File "./zot.py", line 1822, in retrieve_data return self.filter_data(self.retrieve_data_cached(collection_id, exclude)) File "./zot.py", line 1879, in retrieve_data_cached b = self.retrieve_bib(collection_id, 'bibtex', '') File "./zot.py", line 1809, in retrieve_bib return self.retrieve_x(collection, content=content, style=style) File "./zot.py", line 1805, in retrieve_x **args)) File "/usr/lib/python3.7/site-packages/pyzotero/zotero.py", line 225, in wrapped_f parsed = feedparser.parse(retrieved.text) File "/home/yngvelevinsen/.local/lib/python3.7/site-packages/feedparser.py", line 3956, in parse saxparser.parse(source) File "/usr/lib/python3.7/site-packages/drv_libxml2.py", line 239, in parse _d(reader.Name())) File "/home/yngvelevinsen/.local/lib/python3.7/site-packages/feedparser.py", line 2052, in endElementNS self.unknown_endtag(localname) File "/home/yngvelevinsen/.local/lib/python3.7/site-packages/feedparser.py", line 696, in unknown_endtag method() File "/home/yngvelevinsen/.local/lib/python3.7/site-packages/feedparser.py", line 1832, in _end_content value = self.popContent('content') File "/home/yngvelevinsen/.local/lib/python3.7/site-packages/feedparser.py", line 1003, in popContent value = self.pop(tag) File "/home/yngvelevinsen/.local/lib/python3.7/site-packages/feedparser.py", line 886, in pop output = _base64decode(output.encode('utf-8')).decode('utf-8') UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8a in position 0: invalid start byte ```
urschrei commented 5 years ago

Oops sorry! Fixed in 1.4.10, released to PyPI.