From fd99ef86dfca50dbd36b2c1a022cf30a0720dbea Mon Sep 17 00:00:00 2001 From: Paul Tremberth Date: Mon, 18 Jan 2016 17:57:55 +0100 Subject: [PATCH] Test for AttributeError when pickling objects (Python>=3.5) Same "fix" as in e.g. https://github.com/joblib/joblib/pull/246 --- scrapy/squeues.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scrapy/squeues.py b/scrapy/squeues.py index 6e2a60fd2..21520f454 100644 --- a/scrapy/squeues.py +++ b/scrapy/squeues.py @@ -25,7 +25,9 @@ def _serializable_queue(queue_class, serialize, deserialize): def _pickle_serialize(obj): try: return pickle.dumps(obj, protocol=2) - except pickle.PicklingError as e: + # Python>=3.5 raises AttributeError here while + # Python<=3.4 raises pickle.PicklingError + except (pickle.PicklingError, AttributeError) as e: raise ValueError(str(e)) PickleFifoDiskQueue = _serializable_queue(queue.FifoDiskQueue, \