Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#11696 closed defect (fixed)

TypeError: 'Logger' object is not callable

Reported by: John Shue <john@…> Owned by: John Shue <john@…>
Priority: normal Milestone: plugin - mercurial
Component: plugin/mercurial Version: 1.0
Severity: normal Keywords:
Cc: Branch:
Release Notes:

compatibility fix for Mercurial 3.0

API Changes:

Description (last modified by Christian Boos)

How to Reproduce

While doing a GET operation on /timeline, Trac issued an internal error.

Additional details:

This error also occurs when accessing the /browser URL. The issue appears to be caused by a member name collision in the tracext.hg.backend.trac_ui class. The trac_ui class uses trac_ui.log to store a Logger object, but the mercurial.ui base class is using log as a member function:

 def log(self, service, *msg, **opts):
        '''hook for logging facility extensions

        service should be a readily-identifiable subsystem, which will
        allow filtering.
        message should be a newline-terminated string to log.
        '''
        pass

The exception is raised when the mercurial.tags._readtagcache function is expecting trac_ui.log to be a function, when it is an instance of Logger. Here is the code from _readtagcache:

    ui.log('tagscache',
           'resolved %d tags cache entries from %d manifests in %0.4f '
           'seconds\n',
           len(cachefnode), len(newheads), duration)

I was able to fix the error by altering the code in backend.py to rename the trac_ui.log member to trac_ui._log:

  • backend.py

    old new  
    181181    def __init__(self, *args, **kwargs):
    182182        ui.__init__(self, *args)
    183183        self.setconfig('ui', 'interactive', 'off')
    184         self.log = kwargs.get('log', args and args[0].log or None)
     184        self._log = kwargs.get('log', args and args[0]._log or None)
    185185
    186186    def write(self, *args, **opts):
    187187        for a in args:
    188             self.log.info('(mercurial status) %s', a)
     188            self._log.info('(mercurial status) %s', a)
    189189
    190190    def write_err(self, *args, **opts):
    191191        for a in args:
    192             self.log.warn('(mercurial warning) %s', a)
     192            self._log.warn('(mercurial warning) %s', a)
    193193
    194194    def plain(self, *args, **kw):
    195195        return False # so that '[hg] hgrc' file can specify [ui] options

Request parameters:

{}

User agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36

System Information

Trac 1.0
Docutils 0.11
Genshi 0.7 (with speedups)
Mercurial 3.0
mod_wsgi 3.4 (WSGIProcessGroup WSGIApplicationGroup %{GLOBAL})
Pygments 1.6
pysqlite 2.6.0
Python 2.7.6 (default, May 15 2014, 18:23:58)
[GCC 4.2.1 Compatible FreeBSD Clang 3.3 (tags/RELEASE_33/final 183502)]
pytz 2014.3
setuptools 2.0.1
SQLite 3.8.4.3
jQuery 1.7.2

Enabled Plugins

TracMercurial 1.0.0.3dev

Python Traceback

Traceback (most recent call last):
  File "build/bdist.freebsd-10.0-RELEASE-i386/egg/trac/web/main.py", line 497, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.freebsd-10.0-RELEASE-i386/egg/trac/web/main.py", line 233, in dispatch
    content_type)
  File "build/bdist.freebsd-10.0-RELEASE-i386/egg/trac/web/chrome.py", line 1000, in render_template
    encoding='utf-8')
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/core.py", line 184, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/output.py", line 58, in encode
    for chunk in iterator:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/output.py", line 350, in __call__
    for kind, data, pos in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/output.py", line 829, in __call__
    for kind, data, pos in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/output.py", line 669, in __call__
    for kind, data, pos in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/output.py", line 774, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/output.py", line 594, in __call__
    for ev in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "build/bdist.freebsd-10.0-RELEASE-i386/egg/trac/web/chrome.py", line 1137, in _strip_accesskeys
    for kind, data, pos in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "build/bdist.freebsd-10.0-RELEASE-i386/egg/trac/web/chrome.py", line 1126, in _generate
    for kind, data, pos in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/base.py", line 618, in _include
    for event in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/markup.py", line 326, in _match
    for event in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/base.py", line 558, in _flatten
    for kind, data, pos in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/path.py", line 588, in _generate
    subevent = next()
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/base.py", line 618, in _include
    for event in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/markup.py", line 315, in _strip
    event = next()
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/base.py", line 558, in _flatten
    for kind, data, pos in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/core.py", line 289, in _ensure
    for event in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/path.py", line 588, in _generate
    subevent = next()
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/base.py", line 618, in _include
    for event in stream:
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/markup.py", line 315, in _strip
    event = next()
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/base.py", line 578, in _flatten
    result = _eval_expr(data, ctxt, vars)
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/base.py", line 289, in _eval_expr
    retval = expr.evaluate(ctxt)
  File "/usr/local/lib/python2.7/site-packages/Genshi-0.7-py2.7-freebsd-10.0-RELEASE-p3-i386.egg/genshi/template/eval.py", line 177, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "/usr/local/www/apache22/trac/eggs/Trac-1.0-py2.7.egg-tmp/trac/timeline/templates/timeline.html", line 49, in <Expression u"event.render('title', context)">
    <span class="time">${format_time(event.date, 'short')}</span> ${event.render('title', context)}
  File "build/bdist.freebsd-10.0-RELEASE-i386/egg/trac/timeline/web_ui.py", line 355, in <lambda>
    provider.render_timeline_event(context, field, event)
  File "build/bdist.freebsd-10.0-RELEASE-i386/egg/trac/versioncontrol/web_ui/changeset.py", line 1037, in render_timeline_event
    for name in cset.get_tags():
  File "/usr/home/jshue/working/mercurial-plugin/tracext/hg/backend.py", line 1322, in get_tags
    return [self.repos.to_u(t) for t in self.ctx.tags()]
  File "/usr/local/lib/python2.7/site-packages/mercurial/context.py", line 369, in tags
    return self._repo.nodetags(self._node)
  File "/usr/local/lib/python2.7/site-packages/mercurial/localrepo.py", line 675, in nodetags
    if not self._tagscache.nodetagscache:
  File "/usr/local/lib/python2.7/site-packages/mercurial/util.py", line 287, in __get__
    result = self.func(obj)
  File "/usr/local/lib/python2.7/site-packages/mercurial/localrepo.py", line 598, in _tagscache
    cache.tags, cache.tagtypes = self._findtags()
  File "/usr/local/lib/python2.7/site-packages/mercurial/localrepo.py", line 635, in _findtags
    tagsmod.findglobaltags(self.ui, self, alltags, tagtypes)
  File "/usr/local/lib/python2.7/site-packages/mercurial/tags.py", line 31, in findglobaltags
    (heads, tagfnode, cachetags, shouldwrite) = _readtagcache(ui, repo)
  File "/usr/local/lib/python2.7/site-packages/mercurial/tags.py", line 261, in _readtagcache
    len(cachefnode), len(newheads), duration)
TypeError: 'Logger' object is not callable

Attachments (0)

Change History (5)

comment:1 by Christian Boos, 5 years ago

Description: modified (diff)
Milestone: plugin - mercurial
Release Notes: modified (diff)

Nice catch!

I upgraded to Mercurial 3.1-rc this morning and now I also see this, after forcing a tag cache update (touch .hg/tags.cache).

That ui.log() method is there since 1.7 apparently… but this is the first time we get caught by this (3.0 introduced this precise call).

Thanks for the patch, which works for me as well.

comment:2 by Christian Boos, 5 years ago

Resolution: fixed
Status: newclosed

Fix pushed in [211357abe5c0/mercurial-plugin] (0.12) and [3bf996dd58c7/mercurial-plugin] (1.0).

Thanks!

comment:3 by Christian Boos, 5 years ago

Owner: set to John Shue <john@…>

comment:4 by Christian Boos, 5 years ago

See also #11811.

comment:5 by Ryan J Ollos, 4 years ago

#12258 closed as a duplicate.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain John Shue <john@…>.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.