Ticket #3261 (closed defect: fixed)
PHP highlighter treats content as string (really a stream)
| Reported by: | Tim Hatch <trac@…> | Owned by: | mgood |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.10 |
| Component: | version control/browser | Version: | devel |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I noticed this while tracking down 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() (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
Attachments
Change History
Note: See
TracTickets for help on using
tickets.



