#12798 closed defect (fixed)
/timeline?max=10format=rss page dumps raw stack trace
| Reported by: | Jun Omae | Owned by: | Jun Omae |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.3.2 |
| Component: | timeline | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: |
|
||
Description (last modified by )
/timeline?max=10format=rss page dumps raw stack trace (query string has no & characters).
Traceback (most recent call last):
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/web/api.py", line 784, in send_error
metadata)
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/web/chrome.py", line 1410, in render_template
fragment, iterable, method)
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/web/chrome.py", line 1502, in _render_jinja_template
iterable)
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/web/chrome.py", line 1616, in generate_template_stream
bytes = template.render(data).encode('utf-8')
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/templates/error.html", line 89, in top-level template code
<input type="submit" name="create" value="${_('Create')}" />
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/templates/layout.html", line 12, in top-level template code
# import "macros.html" as jmacros with context
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/templates/theme.html", line 22, in top-level template code
# block body
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/templates/theme.html", line 128, in block "body"
# block content
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/templates/error.html", line 186, in block "content"
${faulty_plugins|map('name')|join(', ')}
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/jinja2/filters.py", line 322, in do_join
value = list(value)
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/jinja2/filters.py", line 852, in do_map
yield func(item)
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/jinja2/filters.py", line 984, in <lambda>
name, item, args, kwargs, context=context)
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/jinja2/environment.py", line 451, in call_filter
fail_for_missing_callable('no filter named %r', name)
File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/jinja2/environment.py", line 97, in fail_for_missing_callable
raise TemplateRuntimeError(msg)
TemplateRuntimeError: no filter named 'name'
Attachments (1)
Change History (17)
comment:1 by , 9 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 9 years ago
comment:3 by , 9 years ago
Hmm.
- If logged in, got
TemplateRuntimeError: no filter named 'name'. - If not logged in, got
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-7: ordinal not in range(128).
It might be caused by the session data. Also, I'm configuring Japanese in preferences panel to confirm localized messages on trunk.
by , 9 years ago
| Attachment: | Screen Shot 2017-05-08 at 02.10.14.png added |
|---|
follow-ups: 8 13 comment:6 by , 9 years ago
I got second error on my development environment with Japanese and compiled catalog.
2017-05-08 18:41:43,633 Trac[main] ERROR: [192.168.11.23] Internal Server Error: <RequestWithSession "GET '/timeline?max=abc'">, referrer 'http://192.168.11.27:3000/1.3-sqlite/timeline?max=abc'
Traceback (most recent call last):
File "/home/jun66j5/src/tracdev/git/trac/web/main.py", line 640, in _dispatch_request
dispatcher.dispatch(req)
File "/home/jun66j5/src/tracdev/git/trac/web/main.py", line 242, in dispatch
resp = chosen_handler.process_request(req)
File "/home/jun66j5/src/tracdev/git/trac/timeline/web_ui.py", line 95, in process_request
maxrows = req.args.getint('max', 50 if format == 'rss' else 0)
File "/home/jun66j5/src/tracdev/git/trac/web/api.py", line 400, in getint
"%(name)s.", name=tag.em(name)))
File "/home/jun66j5/src/tracdev/git/trac/web/api.py", line 246, in __init__
self.detail))
File "/home/jun66j5/src/tracdev/git/trac/util/html.py", line 354, in __str__
return str(self.__unicode__())
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-7: ordinal not in range(128)
It seems the following patch fixes it.
-
trac/util/html.py
diff --git a/trac/util/html.py b/trac/util/html.py index 9eca3076c..bfb666760 100644
a b class Fragment(object): 351 351 return u''.join(escape(c, False) for c in self.children) 352 352 353 353 def __str__(self): 354 return s tr(self.__unicode__())354 return self.__unicode__().encode('utf-8') 355 355 356 356 def __add__(self, other): 357 357 return Fragment(self, other) -
trac/web/api.py
diff --git a/trac/web/api.py b/trac/web/api.py index 6a0dc3658..345b38861 100644
a b class HTTPException(TracBaseError): 241 241 self.detail = detail 242 242 if args: 243 243 self.detail = self.detail % args 244 super(HTTPException, self).__init__( '%s %s (%s)' % (self.code,245 self.reason,246 self.detail))244 super(HTTPException, self).__init__(u'%s %s (%s)' % (self.code, 245 self.reason, 246 self.detail)) 247 247 248 248 @property 249 249 def message(self):
Another issue, I think __slot__ in Fragment is typo….
class Fragment(object):
"""A fragment represents a sequence of strings or elements."""
- __slot__ = ('children')
+ __slots__ = ('children',)
$ git grep -w '__slot__' -- '*.py'
trac/util/html.py: __slot__ = ('children')
trac/util/html.py: __slot__ = ('tag', 'attrib')
trac/util/html.py: __slot__ = ()
comment:7 by , 9 years ago
The root cause is located at:
-
trac/templates/error.html
diff --git a/trac/templates/error.html b/trac/templates/error.html index 141b7d885..5e7b809e3 100644
a b 183 183 Note that the following plugins seem to be involved: 184 184 185 185 # endtrans 186 ${faulty_plugins|map( 'name')|join(', ')}186 ${faulty_plugins|map(attribute='name')|join(', ')} 187 187 # endif 188 188 <strong> 189 189 ${_("Please report this issue to the plugin maintainer.")}
follow-up: 9 comment:8 by , 8 years ago
comment:9 by , 8 years ago
Replying to Jun Omae:
Replying to Jun Omae:
Another issue, I think
__slot__inFragmentis typo….Fixed in [15911].
Nice catch, sorry for the typo.
However, wouldn't self.attrib = self._dict_from_kwargs(kwargs) if kwargs else {} be slightly less efficient as it creates an empty dict each time there's no attributes for an element?
follow-up: 11 comment:10 by , 8 years ago
First, I just replaced __slot__ with __slots__ in Fragment class. However, the following errors occurred.
Traceback (most recent call last):
File "/src/tracdev/git/trac/util/tests/html.py", line 295, in test_tracerror_with_tracerror_with_fragment
tag.a('Trac', href='http://trac.edgewall.org/'))
File "/src/tracdev/git/trac/util/html.py", line 431, in __call__
self.attrib = d
AttributeError: 'Element' object attribute 'attrib' is read-only
Reconsidering…, I noticed we could do like this (unit tests passed). Thoughts?
-
trac/util/html.py
diff --git a/trac/util/html.py b/trac/util/html.py index ff77295ea..c1dbd3ba6 100644
a b class XMLElement(Fragment): 395 395 396 396 __slots__ = ('tag', 'attrib') 397 397 398 EMPTY_ATTRIB = {} 399 398 400 VOID_ELEMENTS = () 399 401 400 402 CLOSE_TAG = u'/>' … … class XMLElement(Fragment): 402 404 def __init__(self, tag, *args, **kwargs): 403 405 Fragment.__init__(self, *args) 404 406 self.tag = unicode(tag) 405 self.attrib = self._dict_from_kwargs(kwargs) if kwargs else {} 407 self.attrib = self._dict_from_kwargs(kwargs) \ 408 if kwargs else self.EMPTY_ATTRIB 406 409 407 410 def _attr_value(self, k, v): 408 411 return v
follow-up: 12 comment:11 by , 8 years ago
Replying to Jun Omae:
First, I just replaced
__slot__with__slots__inFragmentclass. However, the following errors occurred.AttributeError: 'Element' object attribute 'attrib' is read-only
Ah, right, I overlooked this part of the __slots__ mechanism:
__slots__are implemented at the class level by creating descriptors for each variable name. As a result, class attributes cannot be used to set default values for instance variables defined by__slots__; otherwise, the class attribute would overwrite the descriptor assignment. — 3.4.2.4. __slots__
Reconsidering…, I noticed we could do like this (unit tests passed). Thoughts?
Yes, I think that's what we should do.
$ python -mtimeit -s'empty=dict()' '[empty for e in xrange(0,1000)]' 10000 loops, best of 3: 33 usec per loop $ python -mtimeit -s'empty=dict()' '[dict() for e in xrange(0,1000)]' 10000 loops, best of 3: 135 usec per loop $ python -mtimeit -s'empty=dict()' '[{} for e in xrange(0,1000)]' 10000 loops, best of 3: 67.4 usec per loop
comment:12 by , 8 years ago
comment:13 by , 8 years ago
comment:14 by , 8 years ago
| Release Notes: | modified (diff) |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
comment:15 by , 8 years ago
| Owner: | set to |
|---|




I don't get a traceback when I navigate there.