Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Test for AttributeError when pickling objects (Python>=3.5)

Paul Tremberthfd99ef86dfca
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, \