Opened 10 years ago
Closed 10 years ago
#12258 closed defect (duplicate)
TypeError: 'Logger' object is not callable
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | plugin/mercurial | Version: | 1.0.2 |
| Severity: | normal | Keywords: | TypeError Logger mercurial python ui needinfo |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description (last modified by )
When loading the webpage /trac/<project>/browser/<dir>, the following error is displayed:
TypeError: 'Logger' object is not callable
This Bug is related to Bug #11696, Whereas the therein mentioned fix didnt work for me.
The problem is (again) the ui.log(...) function used by mercurial. The (temporary) fix is to:
Insert a
if (hasattr(obj, '__call__')):
and change the indentation. Both Trac and hgwebdir.cgi/.wsgi are working that way.
Unfortunately, these changes will be gone as soon as mercurial gets an update.
My suggestion would be refactoring the Logger object 'log' to 'logger' or maybe 'log_trac'/'trac_log' to avoid further issues.
As for background information:
Debian 8 (jessie) trac 1.0.2 mercurial 3.1.2 trac-mercurial 1.0.0.3 python 2.7.9
Backtraces:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 512, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 221, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/lib/python2.7/dist-packages/trac/versioncontrol/web_ui/browser.py", line 424, in process_request
quickjump_data = list(repos.get_quickjump_entries(rev))
File "/usr/lib/python2.7/dist-packages/tracext/hg/backend.py", line 643, in get_quickjump_entries
for b, n in self.repo.branchtags().items():
File "/usr/lib/python2.7/dist-packages/tracext/hg/backend.py", line 175, in get_branchtags
for bn, heads in repo.branchmap().iteritems():
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 704, in branchmap
branchmap.updatecache(self)
File "/usr/lib/python2.7/dist-packages/mercurial/branchmap.py", line 92, in updatecache
partial = subset.branchmap().copy()
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 704, in branchmap
branchmap.updatecache(self)
File "/usr/lib/python2.7/dist-packages/mercurial/branchmap.py", line 92, in updatecache
partial = subset.branchmap().copy()
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 704, in branchmap
branchmap.updatecache(self)
File "/usr/lib/python2.7/dist-packages/mercurial/branchmap.py", line 92, in updatecache
partial = subset.branchmap().copy()
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 704, in branchmap
branchmap.updatecache(self)
File "/usr/lib/python2.7/dist-packages/mercurial/branchmap.py", line 97, in updatecache
partial.update(repo, revs)
File "/usr/lib/python2.7/dist-packages/mercurial/branchmap.py", line 286, in update
repo.filtername, duration)
TypeError: 'Logger' object is not callable
and
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 512, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 221, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/lib/python2.7/dist-packages/trac/versioncontrol/web_ui/browser.py", line 424, in process_request
quickjump_data = list(repos.get_quickjump_entries(rev))
File "/usr/lib/python2.7/dist-packages/tracext/hg/backend.py", line 652, in get_quickjump_entries
tagslist = self.repo.tagslist()
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 674, in tagslist
if not self._tagscache.tagslist:
File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 319, in __get__
result = self.func(obj)
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 608, in _tagscache
cache.tags, cache.tagtypes = self._findtags()
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 645, in _findtags
tagsmod.findglobaltags(self.ui, self, alltags, tagtypes)
File "/usr/lib/python2.7/dist-packages/mercurial/tags.py", line 32, in findglobaltags
(heads, tagfnode, cachetags, shouldwrite) = _readtagcache(ui, repo)
File "/usr/lib/python2.7/dist-packages/mercurial/tags.py", line 297, in _readtagcache
len(cachefnode), len(newheads), duration)
TypeError: 'Logger' object is not callable
As for the second one, ui.log(…) is not only used in _readtagcache(ui, repo), but also in _writetagcache(ui, repo). I noticed this while editing the file and didnt produce an additional traceback.
Attachments (0)
Change History (8)
follow-up: 3 comment:1 by , 10 years ago
| Keywords: | needinfo added |
|---|
comment:2 by , 10 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 10 years ago
Replying to Christian Boos:
You mention having
trac-mercurial 1.0.0.3, so you actually don't have the fix from #11696, I believe.
According to the table 'Plugins in Debian' on TracOnDebian, only trac-mercurial-1.0.0.3 is available for Debian 8 jessie. Maybe i have read wrong, but the issue described in #11696 was in 1.0.0.3dev and fixed in 1.0.0.3.
Please try upgrading the TracMercurial plugin to 1.0.0.4 first.
Please note that installing from source is not a valid option for me, as I'm not setting up Trac for myself in private, and easy-to-upgrade via apt-get is a must-have.
As for the fix I presented, forget it. It made some parts of the hgwebdir.cgi unusable, which i should have expected.
comment:4 by , 10 years ago
| Description: | modified (diff) |
|---|
follow-up: 6 comment:5 by , 10 years ago
A little update: Manually applying the patch of #11696 lead to:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 512, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 221, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/lib/python2.7/dist-packages/trac/versioncontrol/web_ui/browser.py", line 345, in process_request
reponame, repos, path = rm.get_repository_by_path(path)
File "/usr/lib/python2.7/dist-packages/trac/versioncontrol/api.py", line 603, in get_repository_by_path
return (reponame, self.get_repository(reponame),
File "/usr/lib/python2.7/dist-packages/trac/versioncontrol/api.py", line 579, in get_repository
repoinfo.copy())
File "/usr/lib/python2.7/dist-packages/tracext/hg/backend.py", line 438, in get_repository
repos = MercurialRepository(dir, params, self.log, self)
File "/usr/lib/python2.7/dist-packages/tracext/hg/backend.py", line 561, in __init__
self.repo = hg.repository(ui=self.ui, path=str_path)
File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 119, in repository
peer = _peerorrepo(ui, path, create)
File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 106, in _peerorrepo
obj = _peerlookup(path).instance(ui, path, create)
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 1777, in instance
return localrepository(ui, util.urllocalpath(path), create)
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 211, in __init__
self.ui.readconfig(self.join("hgrc"), self.root)
File "/usr/lib/python2.7/dist-packages/mercurial/ui.py", line 87, in readconfig
trusted = sections or trust or self._trusted(fp, filename)
File "/usr/lib/python2.7/dist-packages/mercurial/ui.py", line 74, in _trusted
'user %s, group %s\n') % (f, user, group))
File "/usr/lib/python2.7/dist-packages/mercurial/ui.py", line 714, in warn
self.write_err(*msg, **opts)
File "/usr/lib/python2.7/dist-packages/tracext/hg/backend.py", line 192, in write_err
self.__log_.warn('(mercurial warning) %s', a)
AttributeError: 'function' object has no attribute 'warn'
I think the problem is here:
tracext/hg/backend.py:184
self._log = kwargs.get('log', args and args[0].log or None)
The class trac_ui seems to be a subclass of ui of mercurial. In the ui class, log is used as a function, and my guess would be that you tried to make it use your log with this subclass and overwriting the corresponding functions. However, it is fascinating that the usage of kwargs seems to return a log-function, and not your logger-object. I'm not an expert in python, so I cant really understand your code.
comment:6 by , 10 years ago
Replying to m.krehl@hs-furtwangen.de:
I think the problem is here:
tracext/hg/backend.py:184 self._log = kwargs.get('log', args and args[0].log or None)
That issue appears to be fixed in #11811, which is referenced in #11696.
Rather than patching, I think you'd be better off just testing 1.0.0.4 or later and if the issues are corrected ask the Debian maintainers to update the package.
comment:7 by , 10 years ago
Well, seems like i really wasted some time (and yours). Applying both fixes worked.
Thank you.
I'll go ask the Debian Maintainers why they can't update a package to a version that's around for a year ;)
comment:8 by , 10 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Thanks for the fast reply. Closing as duplicate of #11696.



You mention having
trac-mercurial 1.0.0.3, so you actually don't have the fix from #11696, I believe.Please try upgrading the TracMercurial plugin to 1.0.0.4 first.