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
This commit is contained in:
Yaroslav Halchenko 2015-12-18 16:16:05 -05:00
parent a5db7f862c
commit 4f49aab7c0
1 changed files with 2 additions and 2 deletions

View File

@ -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)