#3261: PHP highlighter treats content as string (really a stream)
-------------------------------------------+--------------------------------
 Reporter:  Tim Hatch <[EMAIL PROTECTED]>  |       Owner:  jonas
     Type:  defect                         |      Status:  new  
 Priority:  normal                         |   Milestone:       
Component:  browser                        |     Version:  devel
 Severity:  normal                         |    Keywords:       
-------------------------------------------+--------------------------------
 I noticed this while tracking down [ticket:3260 another php-related
 rendering bug].  The PHP renderer is never being used on my system because
 it triggers an exception.  The {{{content}}} passed into {{{render()}}}
 ([source:trunk/trac/mimeview/php.py mimeview/php.py]) is a stream object,
 not a string.  Stream objects don't seem to include the {{{encode}}}
 member, but if you toss a {{{.read()}}} in there before {{{encode}}} it
 works fine (and simpler than wrapping it with an encoder instance).
 Attaching the simple patch in a sec.

 {{{
 2006-06-13 08:57:51,381 Trac[api] DEBUG: Trying to render HTML preview
 using PHPRenderer
 2006-06-13 08:57:51,384 Trac[php] DEBUG: PHP command line: php -sn
 2006-06-13 08:57:51,385 Trac[api] WARNING: HTML preview using
 <trac.mimeview.php.PHPRenderer object at 0x412511ac> failed (Stream
 instance has no attribute 'encode')
 Traceback (most recent call last):
   File "/usr/lib/python2.3/site-packages/trac/mimeview/api.py", line 402,
 in render
     return Markup(self._annotate(result, annotations))
   File "/usr/lib/python2.3/site-packages/trac/mimeview/api.py", line 436,
 in _annotate
     for num, line in enumerate(_html_splitlines(lines)):
   File "/usr/lib/python2.3/site-packages/trac/mimeview/api.py", line 566,
 in _html_splitlines
     for line in lines:
   File "/usr/lib/python2.3/site-packages/trac/mimeview/php.py", line 67,
 in render
     np = NaivePopen(cmdline, content.encode('utf-8'), capturestderr=1)
 AttributeError: Stream instance has no attribute 'encode'
 2006-06-13 08:57:51,386 Trac[api] DEBUG: Trying to render HTML preview
 using SilverCityRenderer
 }}}

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/3261>
The Trac Project <http://trac.edgewall.com/>
_______________________________________________
Trac-Tickets mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-tickets

Reply via email to