id,summary,reporter,owner,description,type,status,priority,component,severity,resolution,keywords,cc,release
7519,[Patch] "view as plaintext" results in unicode error (0.12 compatibility),charlesc-web-feedback-trac-hacks.org@pyropus.ca,otaku42,Using TracPaste 0.2 and Trac 0.12.  Created a paste containing this_ which is all straight ASCII:\r\n{{{\r\nmyfunc () {\r\n  pat="$1"\r\n  repl="$2"\r\n\r\n  find . -name ... | sed "s/$pat/$repl/g"\r\n}\r\n\r\nmyfunc old1 new1\r\nmyfunc old2 new2\r\n}}}\r\n\r\nThis paste views fine_ but if you select the "plain text" link at the bottom of the page_ it then throws a unicode exception:\r\n\r\n{{{\r\nOops…\r\nTrac detected an internal error:\r\n\r\nValueError: Can't send unicode content\r\n\r\nPython Traceback\r\nMost recent call last:\r\n\r\n    * 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\r\n      Code fragment:\r\n      Line	\r\n      508	try:\r\n      509	if not env and env_error:\r\n      510	raise HTTPInternalError(env_error)\r\n      511	try:\r\n      512	dispatcher = RequestDispatcher(env)\r\n      513	dispatcher.dispatch(req)\r\n      514	except RequestDone:\r\n      515	pass\r\n      516	resp = req._response or []\r\n      517	 \r\n      518	except HTTPException_ e:\r\n      Local variables:\r\n      Name	Value\r\n      dispatcher 	<trac.web.main.RequestDispatcher object at 0x2416190>\r\n      e 	ValueError("Can't send unicode content"_)\r\n      env 	<trac.env.Environment object at 0x1bbc890>\r\n      env_error 	None\r\n      req 	<Request "GET '/pastebin/103'">\r\n      resp 	[]\r\n    * 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\r\n      Code fragment:\r\n      Line	\r\n      230	msg = _('Do you have cookies enabled?')\r\n      231	raise HTTPBadRequest(_('Missing or invalid form token.'\r\n      232	' %(msg)s'_ msg=msg))\r\n      233	 \r\n      234	# Process the request and render the template\r\n      235	resp = chosen_handler.process_request(req)\r\n      236	if resp:\r\n      237	if len(resp) == 2: # Clearsilver\r\n      238	chrome.populate_hdf(req)\r\n      239	template_ content_type = \\\r\n      240	self._post_process_request(req_ *resp)\r\n      Local variables:\r\n      Name	Value\r\n      chosen_handler 	<tracpaste.web_ui.TracpastePlugin object at 0x24165d0>\r\n      chrome 	<trac.web.chrome.Chrome object at 0x2407d50>\r\n      err 	(<type 'exceptions.ValueError'>_ ValueError("Can't send unicode ...\r\n      handler 	<tracpaste.web_ui.TracpastePlugin object at 0x24165d0>\r\n      req 	<Request "GET '/pastebin/103'">\r\n      self 	<trac.web.main.RequestDispatcher object at 0x2416190>\r\n    * 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\r\n      Code fragment:\r\n      Line	\r\n      159	req.send_response(200)\r\n      160	req.send_header('Content-Type'_ mimetype)\r\n      161	req.send_header('Content-Length'_ len(paste.data))\r\n      162	req.send_header('Last-Modified'_ http_date(paste.time))\r\n      163	req.end_headers()\r\n      164	req.write(paste.data)\r\n      165	return\r\n      166	else:\r\n      167	self.env.log.info("*** download denied")\r\n      168	 \r\n      169	data = {\r\n      Local variables:\r\n      Name	Value\r\n      mimetype 	'text/plain'\r\n      paste 	<Paste u'untitled': 103>\r\n      req 	<Request "GET '/pastebin/103'">\r\n      self 	<tracpaste.web_ui.TracpastePlugin object at 0x24165d0>\r\n    * 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\r\n      Code fragment:\r\n      Line	\r\n      525	if not self._write:\r\n      526	self.end_headers()\r\n      527	if not hasattr(self_ '_content_length'):\r\n      528	raise RuntimeError("No Content-Length header set")\r\n      529	if isinstance(data_ unicode):\r\n      530	raise ValueError("Can't send unicode content")\r\n      531	try:\r\n      532	self._write(data)\r\n      533	except (IOError_ socket.error)_ e:\r\n      534	if e.args[0] in (errno.EPIPE_ errno.ECONNRESET_ 10053_ 10054):\r\n      535	raise RequestDone\r\n      Local variables:\r\n      Name	Value\r\n      data 	u'myfunc () {\\r\\n pat="$1"\\r\\n repl="$2"\\r\\n\\r\\n find . -name ... | sed ...\r\n      self 	<Request "GET '/pastebin/103'">\r\n\r\nFile "/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\r\n  dispatcher.dispatch(req)\r\nFile "/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\r\n  resp = chosen_handler.process_request(req)\r\nFile "/var/www/dev.fatdrop.co.uk/trac-env/plugins/TracPaste-0.2-py2.5.egg/tracpaste/web_ui.py"_ line 164_ in process_request\r\n  req.write(paste.data)\r\nFile "/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\r\n  raise ValueError("Can't send unicode content")\r\n\r\n\r\nSystem Information:\r\n\r\nUser 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\r\nTrac 	0.12\r\nDocutils 	0.8\r\nGenshi 	0.6\r\nmod_wsgi 	2.8 (WSGIProcessGroup xyz_trac WSGIApplicationGroup domain.example.net|)\r\nPygments 	1.3.1\r\npysqlite 	2.4.0\r\nPython 	2.5.2 (r252:60911_ Jan 20 2010_ 23:30:56) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)]\r\nsetuptools 	0.6c9\r\nSQLite 	3.4.2\r\nSubversion 	1.5.1 (r32289)\r\njQuery	1.2.6\r\n\r\n\r\nEnabled Plugins:\r\nBlackMagicTicketTweaks 	0.12r1 	/var/www/domain.example.net/trac-env/plugins/BlackMagicTicketTweaks-0.12r1-py2.5.egg\r\nScreamer 	0.6.0 	/var/www/domain.example.net/trac-env/plugins/Screamer-0.6.0-py2.5.egg\r\ntimingandestimationplugin 	1.0.6 	/var/www/domain.example.net/trac-env/plugins/timingandestimationplugin-1.0.6-py2.5.egg\r\nTracBurndown 	1.9.2 	/var/www/domain.example.net/trac-env/plugins/TracBurndown-1.9.2-py2.5.egg\r\nTracPaste 	0.2 	/var/www/domain.example.net/trac-env/plugins/TracPaste-0.2-py2.5.egg\r\nTracWikiNotification 	0.2.1 	/var/www/domain.example.net/trac-env/plugins/TracWikiNotification-0.2.1-py2.5.egg\r\n}}}\r\n\r\n\r\n,defect,closed,normal,TracPastePlugin,normal,fixed,,lkraav,0.12
