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
