From 4f49aab7c068c553c5dcb2935ee3e4df6c0b71aa Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 18 Dec 2015 16:16:05 -0500 Subject: [PATCH] BF: robustify _monkeypatches check for twisted - str() name first (Closes: #1634) In my case, while running datalad tests using nose, scrapy was failing since v was None --- scrapy/_monkeypatches.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scrapy/_monkeypatches.py b/scrapy/_monkeypatches.py index 782891326..60e0de1f2 100644 --- a/scrapy/_monkeypatches.py +++ b/scrapy/_monkeypatches.py @@ -20,6 +20,6 @@ if sys.version_info[0] == 2: import twisted.persisted.styles # NOQA # Remove only entries with twisted serializers for non-twisted types. for k, v in frozenset(copyreg.dispatch_table.items()): - if not getattr(k, '__module__', '').startswith('twisted') \ - and getattr(v, '__module__', '').startswith('twisted'): + if not str(getattr(k, '__module__', '')).startswith('twisted') \ + and str(getattr(v, '__module__', '')).startswith('twisted'): copyreg.dispatch_table.pop(k)