Issue #25 duplicate

demandimport error - Issue with Google back end

Alejandro Giacometti
created an issue

Mercurial is unable to import keyring due to some error with the gdata back end.

Here is the traceback:

*** failed to import extension mercurial_keyring: 'module' object has no attribute 'service'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/mercurial/extensions.py", line 92, in loadall
    load(ui, name, path)
  File "/usr/local/lib/python2.7/site-packages/mercurial/extensions.py", line 79, in load
    mod = importh(name)
  File "/usr/local/lib/python2.7/site-packages/mercurial/extensions.py", line 69, in importh
    mod = __import__(name)
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
    return _import(name, globals, locals, fromlist, level)
  File "/usr/local/lib/python2.7/site-packages/mercurial_keyring.py", line 61, in <module>
    import keyring
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
    return _import(name, globals, locals, fromlist, level)
  File "/usr/local/lib/python2.7/site-packages/keyring/__init__.py", line 9, in <module>
    from core import (set_keyring, get_keyring, set_password, get_password,
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 114, in _demandimport
    mod = _origimport(name, globals, locals)
  File "/usr/local/lib/python2.7/site-packages/keyring/core.py", line 166, in <module>
    init_backend()
  File "/usr/local/lib/python2.7/site-packages/keyring/core.py", line 63, in init_backend
    keyrings = backend.get_all_keyring()
  File "/usr/local/lib/python2.7/site-packages/keyring/util/__init__.py", line 24, in wrapper
    func.always_returns = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/keyring/backend.py", line 94, in get_all_keyring
    exceptions=TypeError))
  File "/usr/local/lib/python2.7/site-packages/keyring/util/__init__.py", line 37, in suppress_exceptions
    yield callable()
  File "/usr/local/lib/python2.7/site-packages/keyring/backends/Google.py", line 308, in __init__
    credential, source, crypter)
  File "/usr/local/lib/python2.7/site-packages/keyring/backends/Google.py", line 43, in __init__
    DocsService = (__import__('gdata.docs.service')
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
    return _import(name, globals, locals, fromlist, level)
  File "/usr/local/lib/python2.7/site-packages/gdata/docs/service.py", line 83, in <module>
    class DocsService(gdata.service.GDataService):
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 86, in __getattribute__
    self._load()
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 58, in _load
    mod = _origimport(head, globals, locals)
  File "/usr/local/lib/python2.7/site-packages/gdata/service.py", line 123, in <module>
    http_request_handler = atom.service
  File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 87, in __getattribute__
    return getattr(self._module, attr)
AttributeError: 'module' object has no attribute 'service'

Comments (7)

  1. Marcin Kasperski repo owner

    Yeah, demandimport, yeah.... This is really hostile towards extensions which happen to import something.

    I added gdata.service and gdata.docs.service, can't guarantee whether it helps as I do not use gdata myself (https://bitbucket.org/Mekk/mercurial_keyring/commits/067e97c310e123805a955934bd8681bb27b5fa1f). The fix will be present in next release (or you can test it grabbing mercurial_keyring.py from source).

    I close the issue, if it happens it does not help, please reopen it and provide next traceback (or, even better, experiment yourself what to add, this is simply adding problematic modules to the ignore list).

  2. Alejandro Giacometti reporter

    Thanks for trying to fix this!

    Unfortunately, the issue is still unresolved:

    *** failed to import extension mercurial_keyring: 'module' object has no attribute 'service'
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/site-packages/mercurial/extensions.py", line 92, in loadall
        load(ui, name, path)
      File "/usr/local/lib/python2.7/site-packages/mercurial/extensions.py", line 79, in load
        mod = importh(name)
      File "/usr/local/lib/python2.7/site-packages/mercurial/extensions.py", line 69, in importh
        mod = __import__(name)
      File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
        return _import(name, globals, locals, fromlist, level)
      File "/usr/local/lib/python2.7/site-packages/mercurial_keyring.py", line 66, in <module>
        import keyring
      File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
        return _import(name, globals, locals, fromlist, level)
      File "/usr/local/lib/python2.7/site-packages/keyring/__init__.py", line 9, in <module>
        from core import (set_keyring, get_keyring, set_password, get_password,
      File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 114, in _demandimport
        mod = _origimport(name, globals, locals)
      File "/usr/local/lib/python2.7/site-packages/keyring/core.py", line 166, in <module>
        init_backend()
      File "/usr/local/lib/python2.7/site-packages/keyring/core.py", line 63, in init_backend
        keyrings = backend.get_all_keyring()
      File "/usr/local/lib/python2.7/site-packages/keyring/util/__init__.py", line 24, in wrapper
        func.always_returns = func(*args, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/keyring/backend.py", line 94, in get_all_keyring
        exceptions=TypeError))
      File "/usr/local/lib/python2.7/site-packages/keyring/util/__init__.py", line 37, in suppress_exceptions
        yield callable()
      File "/usr/local/lib/python2.7/site-packages/keyring/backends/Google.py", line 308, in __init__
        credential, source, crypter)
      File "/usr/local/lib/python2.7/site-packages/keyring/backends/Google.py", line 43, in __init__
        DocsService = (__import__('gdata.docs.service')
      File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
        return _import(name, globals, locals, fromlist, level)
      File "/usr/local/lib/python2.7/site-packages/gdata/docs/service.py", line 34, in <module>
        import gdata.service
      File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
        return _import(name, globals, locals, fromlist, level)
      File "/usr/local/lib/python2.7/site-packages/gdata/service.py", line 123, in <module>
        http_request_handler = atom.service
      File "/usr/local/lib/python2.7/site-packages/mercurial/demandimport.py", line 87, in __getattribute__
        return getattr(self._module, attr)
    AttributeError: 'module' object has no attribute 'service'
    
  3. Marcin Kasperski repo owner

    Unfortunately I need help.

    Could you either:

    a) play yourself with demandimport quotes for a moment (nothing hard, just open mercurial_keyring.py wherever it is installed and try adding some more items to the blocked modules list: https://bitbucket.org/Mekk/mercurial_keyring/src/e43a257a2a195e7f5e3db569b661b95beac11ef5/mercurial_keyring.py?at=default#cl-52 - maybe that's about "service", maybe "atom.service", …)

    or

    b) Instruct me how to reproduce the problem starting from scratch (i.e. what should I install and configure to use this gdata backend I never heard of so far)

  4. Log in to comment