Page MenuHomePhabricator

Cache is not usable between Python versions
Closed, DuplicatePublic

Description

The API cache is not operable between Python versions. I do basically this:

>>> import pickle
>>> with open('tests/apicache/735234d1f97ef2e764af8a361be182b3ead3e90b05e56910e9ead87453140d37', 'rb') as f:
...   c = f.read()
... 
>>> pickle.loads(c)

And in Python 2 this works and returns something usable while in Python 3 you only get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xdf in position 1: ordinal not in range(128)

Now this is not much of a problem usually if people stick to their version but considering that pickle shouldn't be trusted with external data I'm wondering if we should cache requests differently. For example in a json files we could utilize that we expect json data itself so we could wrap that data in json itself.

Event Timeline

XZise raised the priority of this task from to Lowest.
XZise updated the task description. (Show Details)
XZise added a project: Pywikibot.
XZise added a subscriber: XZise.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptJun 1 2015, 10:07 AM

Using a JSON file format sounds logical.