Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account 'NoneType' object has no attribute 'startswith' #1634

yarikoptic opened this issue Dec 10, 2015 · 1 comment
Closed 'NoneType' object has no attribute 'startswith' #1634

yarikoptic opened this issue Dec 10, 2015 · 1 comment


Copy link

@yarikoptic yarikoptic commented Dec 10, 2015

Did not try yet to come up with minimal example to demonstrate this issue but it is reproducible for me:

$> datalad --dbg crawl
Traceback (most recent call last):
  File "/home/yoh/proj/datalad/datalad/venv-tests/bin/datalad", line 9, in <module>
    load_entry_point('datalad==0.1.dev0', 'console_scripts', 'datalad')()
  File "/home/yoh/proj/datalad/datalad/datalad/cmdline/", line 199, in main
  File "/home/yoh/proj/datalad/datalad/datalad/interface/", line 151, in call_from_parser
    return self(**kwargs)
  File "/home/yoh/proj/datalad/datalad/datalad/interface/", line 44, in __call__
    from datalad.crawler.pipeline import load_pipeline_from_config, get_pipeline_config_path
  File "/home/yoh/proj/datalad/datalad/datalad/crawler/", line 21, in <module>
    from .newmain import lgr
  File "/home/yoh/proj/datalad/datalad/datalad/crawler/", line 21, in <module>
    from .nodes.matches import *
  File "/home/yoh/proj/datalad/datalad/datalad/crawler/nodes/", line 18, in <module>
    from scrapy.selector import Selector
  File "/home/yoh/proj/datalad/datalad/venv-tests/local/lib/python2.7/site-packages/scrapy/", line 27, in <module>
    from . import _monkeypatches
  File "/home/yoh/proj/datalad/datalad/venv-tests/local/lib/python2.7/site-packages/scrapy/", line 24, in <module>
    and getattr(v, '__module__', '').startswith('twisted'):
AttributeError: 'NoneType' object has no attribute 'startswith'
> /home/yoh/proj/datalad/datalad/venv-tests/local/lib/python2.7/site-packages/scrapy/<module>()
-> and getattr(v, '__module__', '').startswith('twisted'):
(Pdb) l
 19     # to prevent bugs like Twisted#7989 while serializing requests
 20     import twisted.persisted.styles  # NOQA
 21     # Remove only entries with twisted serializers for non-twisted types.
 22     for k, v in frozenset(copyreg.dispatch_table.items()):
 23         if not getattr(k, '__module__', '').startswith('twisted') \
 24  ->             and getattr(v, '__module__', '').startswith('twisted'):
 25             copyreg.dispatch_table.pop(k)
(Pdb) p k
(Pdb) p v
(Pdb) p copyreg

not sure it came to it but the issue is (if I pdb before this madness happens):

(Pdb) p getattr(k, '__module__', '')
(Pdb) p getattr(v, '__module__', '')
(Pdb) p v
<function mpq_reducer at 0x7f474bb4ab90>
(Pdb) p v.__module__
(Pdb) p k, v
(<type 'mpq'>, <function mpq_reducer at 0x7f474bb4ab90>)

so assigned __module__ is None. As a quick resolution wrapped into str() call to assure str there

and str(getattr(v, '__module__', '')).startswith('twisted'):
eliasdorneles added a commit that referenced this issue Jan 13, 2016
[MRG+1] BF: robustify _monkeypatches check for twisted - str() name first (Closes #1634)
Copy link

@redapple redapple commented Feb 2, 2016

Fixed in #1644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.