Opened 17 years ago
Closed 17 years ago
#158 closed defect (fixed)
Unexpected "undefined" error
Reported by: | cboos | Owned by: | cmlenz |
---|---|---|---|
Priority: | major | Milestone: | 0.5 |
Component: | Expression evaluation | Version: | devel |
Keywords: | Cc: |
Description
While stress-testing Trac, I sometimes get weird Genshi errors, using a fairly recent build (0.5dev-r766, well, that's the latest even).
KeyError: <Undefined 'name'>
and the one line backtrace is:
File "...\trunk\trac\ticket\templates\query_results.html", line 48, in <Suite u'name = header.name; value = result[name]'>
The actual line content is:
<py:with vars="name = header.name; value = result[name]">
The data section shows the following for header (with less truncation than usual in order to get the full representation):
header {'href': '/devel/query?group=status&order=owner&milestone=This+is+a+stupid+milestone', 'name': 'owner', 'label': 'Owner'}
As you can see, there's an entry for 'name' here.
Needless to say, when reloading the page after the error, it displays just fine, so it's really a transient error triggered by the testing conditions and probably due to some race condition.
Just another thought: line 47 is
<py:for each="idx, header in enumerate(headers)" py:choose="">
so perhaps it's a bug in enumerate... but that would be scary as well!
How to reproduce
Start tracd, in a new firefox window, open something like twenty tabs, half of them custom query views. Restart tracd. "Load all tabs". If you're lucky, one of the custom query view will show the above backtrace.
Change History (3)
comment:1 in reply to: ↑ description Changed 17 years ago by cboos
- Version changed from 0.4.4 to devel
comment:2 Changed 17 years ago by cboos
This makes the problem go away:
-
genshi/template/eval.py
73 73 lookup = LenientLookup 74 74 elif isinstance(lookup, basestring): 75 75 lookup = {'lenient': LenientLookup, 'strict': StrictLookup}[lookup] 76 self._globals = lookup.globals ()76 self._globals = lookup.globals 77 77 78 78 def __eq__(self, other): 79 79 return (type(other) == type(self)) and (self.code == other.code) … … 139 139 :return: the result of the evaluation 140 140 """ 141 141 __traceback_hide__ = 'before_and_this' 142 _globals = self._globals 142 _globals = self._globals() 143 143 _globals['data'] = data 144 144 return eval(self.code, _globals, {'data': data}) 145 145 … … 161 161 :param data: a mapping containing the data to execute in 162 162 """ 163 163 __traceback_hide__ = 'before_and_this' 164 _globals = self._globals 164 _globals = self._globals() 165 165 _globals['data'] = data 166 166 exec self.code in _globals, data 167 167
Now the real challenge would be to write a unit-test for that ;-)
comment:3 Changed 17 years ago by cmlenz
- Resolution set to fixed
- Status changed from new to closed
Applied in [770]. Thanks!
Correction:
The "restart" is actually not needed in order to reproduce the problem.