Modify ↓
#13039 closed defect (fixed)
TypeError raised when rendering error with chunked encoding
| Reported by: | Jun Omae | Owned by: | Ryan J Ollos |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.3.3 |
| Component: | general | Version: | 1.3dev |
| Severity: | normal | Keywords: | |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: |
Fixed |
||
Description
I get the following error while investigating #13038 with [trac] use_chunked_encoding = enabled.
Exception happened during processing of request from ('192.168.11.29', 50776)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 596, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/home/jun66j5/src/tracdev/git/trac/web/wsgi.py", line 212, in handle_one_request
gateway.run(self.server.application)
File "/home/jun66j5/src/tracdev/git/trac/web/wsgi.py", line 112, in run
response = application(self.environ, self._start_response)
File "trac/web/standalone.py", line 63, in __call__
return self.application(environ, start_response)
File "trac/web/standalone.py", line 94, in __call__
return self.application(environ, start_response)
File "/home/jun66j5/src/tracdev/git/trac/web/main.py", line 632, in dispatch_request
return _dispatch_request(req, env, env_error)
File "/home/jun66j5/venv/py27/local/lib/python2.7/site-packages/memory_profiler.py", line 1072, in wrapper
val = prof(func)(*args, **kwargs)
File "/home/jun66j5/venv/py27/local/lib/python2.7/site-packages/memory_profiler.py", line 659, in f
return func(*args, **kwds)
File "/home/jun66j5/src/tracdev/git/trac/web/main.py", line 672, in _dispatch_request
_send_user_error(req, env, e)
File "/home/jun66j5/src/tracdev/git/trac/web/main.py", line 692, in _send_user_error
req.send_error(sys.exc_info(), status=e.code, env=env, data=data)
File "/home/jun66j5/src/tracdev/git/trac/web/api.py", line 842, in send_error
self.send_header('Content-Length', len(out))
TypeError: object of type 'generator' has no len()
We should ignore [trac] use_chunked_encoding option when rendering the error (untested patch).
-
trac/web/api.py
diff --git a/trac/web/api.py b/trac/web/api.py index 40fbf1493..02a1e22a2 100644
a b class Request(object): 813 813 if env: 814 814 from trac.web.chrome import Chrome, add_stylesheet 815 815 add_stylesheet(self, 'common/css/code.css') 816 metadata = {'content_type': 'text/html'} 816 metadata = {'content_type': 'text/html', 817 'iterable': False} 817 818 try: 818 819 out = Chrome(env).render_template(self, template, data, 819 820 metadata)
Attachments (0)
Change History (9)
follow-up: 3 comment:1 by , 7 years ago
comment:2 by , 7 years ago
| Release Notes: | modified (diff) |
|---|
comment:3 by , 7 years ago
Replying to Ryan J Ollos:
I did some refactoring in rjollos.git:t13039_refactoring.
Looks good to me.
comment:4 by , 7 years ago
comment:5 by , 7 years ago
After this ticket is concluded I'll propose some related changes in #13042.
comment:6 by , 7 years ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:7 by , 7 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Committed to trunk in r16656.
comment:8 by , 6 years ago
| Release Notes: | modified (diff) |
|---|
comment:9 by , 6 years ago
Note:
See TracTickets
for help on using tickets.



Your patch resolves the issue per my testing. Alternatively, would the following be valid?:
trac/web/api.py
Though I suppose the error page doesn't need to be rendered in chunks because it's a fairly small amount of content.
I did some refactoring in rjollos.git:t13039_refactoring.