Small patch to keyword extension ('module' object has no attribute '_parse')

Marcin Kasperski Marcin.Kasperski at softax.com.pl
Mon Nov 5 12:34:42 CST 2007


> This should already have been taken care of in recent versions of
> (backwards compatible) keyword.py at
> <http://www.blacktrash.org/hg/hgkeyword/>. Are you sure your
> version is not outdated?

Well, I cloned it just before installing and trying... Newest change
is:

changeset:   287:62eff490c844
user:        Christian Ebert <blacktrash at gmx.net>
date:        Mon Oct 29 10:55:41 2007 +0100
summary:     Add convert to nokwcommands (fix issue802)

> But looking at the traceback, I believe you can (and should) try
> the non-backwards compatible version from:
> <http://www.blacktrash.org/hg/hg-crew-keyword/>

Considering this patch works for me I will stay with it for now.
I can't imagine it doing anything wrong ;-)

BTW, I found what is going wrong - there is simple name conflict here.
See yourself:

a) If you just try loading dispatch you fail to load it, OK

$ python
Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mercurial import dispatch
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: cannot import name dispatch

.. but ...

b) If you load system libraries, it is not quite so. Here some module
loads system dispatch module which does not offer what we want.

$ python
Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mercurial import commands, cmdutil, context, fancyopts
>>> from mercurial import dispatch
>>> _parse = dispatch._parse
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/var/lib/python-support/python2.4/mercurial/demandimport.py", line 75, in __getattribute__
    return getattr(self._module, attr)
AttributeError: 'module' object has no attribute '_parse'
>> dir(dispatch)
['AmbiguousMethod', 'DispatchError', 'EXPR_GETTER_ID', 'ICriterion', 'IDispatchFunction', 'IDispatchPredicate', 'IDispatchTable', 'IDispatchableExpression', 'IDispatcher', 'IExtensibleFunction', 'IGenericFunction', 'ISeededCriterion', 'ISignature', 'NoApplicableMethods', '_ClassType', '__builtins__', '__doc__', '__file__', '__name__', '__path__', '_cls', 'as', 'generic', 'interfaces', 'on']
>>> print dispatch.__path__
['/var/lib/python-support/python2.4/dispatch']

(/var/lib/python-support/python2.4/dispatch/ is a directory installed
 by python-dispatch package,
 http://packages.debian.org/stable/python/python-dispatch)




More information about the Mercurial mailing list