Modify ↓
#7519 closed defect (fixed)
[Patch] "view as plaintext" results in unicode error (0.12 compatibility)
| Reported by: | Owned by: | Michael Renzmann | |
|---|---|---|---|
| Priority: | normal | Component: | TracPastePlugin |
| Severity: | normal | Keywords: | |
| Cc: | lkraav | Trac Release: | 0.12 |
Description
Using TracPaste 0.2 and Trac 0.12. Created a paste containing this, which is all straight ASCII:
myfunc () {
pat="$1"
repl="$2"
find . -name ... | sed "s/$pat/$repl/g"
}
myfunc old1 new1
myfunc old2 new2
This paste views fine, but if you select the "plain text" link at the bottom of the page, it then throws a unicode exception:
Oops…
Trac detected an internal error:
ValueError: Can't send unicode content
Python Traceback
Most recent call last:
* File "/var/www/dev.fatdrop.co.uk/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/web/main.py", line 513, in _dispatch_request
Code fragment:
Line
508 try:
509 if not env and env_error:
510 raise HTTPInternalError(env_error)
511 try:
512 dispatcher = RequestDispatcher(env)
513 dispatcher.dispatch(req)
514 except RequestDone:
515 pass
516 resp = req._response or []
517
518 except HTTPException, e:
Local variables:
Name Value
dispatcher <trac.web.main.RequestDispatcher object at 0x2416190>
e ValueError("Can't send unicode content",)
env <trac.env.Environment object at 0x1bbc890>
env_error None
req <Request "GET '/pastebin/103'">
resp []
* File "/var/www/dev.fatdrop.co.uk/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/web/main.py", line 235, in dispatch
Code fragment:
Line
230 msg = _('Do you have cookies enabled?')
231 raise HTTPBadRequest(_('Missing or invalid form token.'
232 ' %(msg)s', msg=msg))
233
234 # Process the request and render the template
235 resp = chosen_handler.process_request(req)
236 if resp:
237 if len(resp) == 2: # Clearsilver
238 chrome.populate_hdf(req)
239 template, content_type = \
240 self._post_process_request(req, *resp)
Local variables:
Name Value
chosen_handler <tracpaste.web_ui.TracpastePlugin object at 0x24165d0>
chrome <trac.web.chrome.Chrome object at 0x2407d50>
err (<type 'exceptions.ValueError'>, ValueError("Can't send unicode ...
handler <tracpaste.web_ui.TracpastePlugin object at 0x24165d0>
req <Request "GET '/pastebin/103'">
self <trac.web.main.RequestDispatcher object at 0x2416190>
* File "/var/www/dev.fatdrop.co.uk/trac-env/plugins/TracPaste-0.2-py2.5.egg/tracpaste/web_ui.py", line 164, in process_request
Code fragment:
Line
159 req.send_response(200)
160 req.send_header('Content-Type', mimetype)
161 req.send_header('Content-Length', len(paste.data))
162 req.send_header('Last-Modified', http_date(paste.time))
163 req.end_headers()
164 req.write(paste.data)
165 return
166 else:
167 self.env.log.info("*** download denied")
168
169 data = {
Local variables:
Name Value
mimetype 'text/plain'
paste <Paste u'untitled': 103>
req <Request "GET '/pastebin/103'">
self <tracpaste.web_ui.TracpastePlugin object at 0x24165d0>
* File "/var/www/dev.fatdrop.co.uk/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/web/api.py", line 530, in write
Code fragment:
Line
525 if not self._write:
526 self.end_headers()
527 if not hasattr(self, '_content_length'):
528 raise RuntimeError("No Content-Length header set")
529 if isinstance(data, unicode):
530 raise ValueError("Can't send unicode content")
531 try:
532 self._write(data)
533 except (IOError, socket.error), e:
534 if e.args[0] in (errno.EPIPE, errno.ECONNRESET, 10053, 10054):
535 raise RequestDone
Local variables:
Name Value
data u'myfunc () {\r\n pat="$1"\r\n repl="$2"\r\n\r\n find . -name ... | sed ...
self <Request "GET '/pastebin/103'">
File "/var/www/dev.fatdrop.co.uk/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/web/main.py", line 513, in _dispatch_request
dispatcher.dispatch(req)
File "/var/www/dev.fatdrop.co.uk/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/web/main.py", line 235, in dispatch
resp = chosen_handler.process_request(req)
File "/var/www/dev.fatdrop.co.uk/trac-env/plugins/TracPaste-0.2-py2.5.egg/tracpaste/web_ui.py", line 164, in process_request
req.write(paste.data)
File "/var/www/dev.fatdrop.co.uk/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/web/api.py", line 530, in write
raise ValueError("Can't send unicode content")
System Information:
User Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8
Trac 0.12
Docutils 0.8
Genshi 0.6
mod_wsgi 2.8 (WSGIProcessGroup xyz_trac WSGIApplicationGroup domain.example.net|)
Pygments 1.3.1
pysqlite 2.4.0
Python 2.5.2 (r252:60911, Jan 20 2010, 23:30:56) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)]
setuptools 0.6c9
SQLite 3.4.2
Subversion 1.5.1 (r32289)
jQuery 1.2.6
Enabled Plugins:
BlackMagicTicketTweaks 0.12r1 /var/www/domain.example.net/trac-env/plugins/BlackMagicTicketTweaks-0.12r1-py2.5.egg
Screamer 0.6.0 /var/www/domain.example.net/trac-env/plugins/Screamer-0.6.0-py2.5.egg
timingandestimationplugin 1.0.6 /var/www/domain.example.net/trac-env/plugins/timingandestimationplugin-1.0.6-py2.5.egg
TracBurndown 1.9.2 /var/www/domain.example.net/trac-env/plugins/TracBurndown-1.9.2-py2.5.egg
TracPaste 0.2 /var/www/domain.example.net/trac-env/plugins/TracPaste-0.2-py2.5.egg
TracWikiNotification 0.2.1 /var/www/domain.example.net/trac-env/plugins/TracWikiNotification-0.2.1-py2.5.egg
Attachments (1)
Change History (7)
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
| Summary: | "view as plaintext" results in unicode error → [Patch] "view as plaintext" results in unicode error (0.12 compatibility) |
|---|
Here is a patch. It's a simple fix and I'd be happy to apply it to the repository if given the go-ahead.
Changed 15 years ago by
| Attachment: | tracpasteplugin.r7022.patch added |
|---|
Patch against r7022 of TracPastePlugin
comment:3 Changed 15 years ago by
| Cc: | lkraav added; anonymous removed |
|---|
comment:4 Changed 15 years ago by
Thanks for the patch. Looks good, no objection from my side. Feel free to commit it.
comment:5 Changed 15 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:6 Changed 15 years ago by
Note: See
TracTickets for help on using
tickets.



It appears this may be the same issue that we see in #7556 for the VotePlugin, which PeterLawrence tracked down a solution for in t:#8675.