Ticket #6932: r6692.patch
| File r6692.patch, 1.1 KB (added by trac-ja@…, 4 years ago) |
|---|
-
trac/util/__init__.py
152 152 lbound = max(0, lineno - context) 153 153 ubound = lineno + 1 + context 154 154 155 before = [l.rstrip('\n') for l in lines[lbound:lineno]]156 line = lines[lineno].rstrip('\n')157 after = [l.rstrip('\n') for l in lines[lineno + 1:ubound]]158 155 156 charset = None 157 rep = re.compile('coding[=:]\s*([-\w.]+)') 158 for linestr in lines[0], lines[1]: 159 match = rep.search(linestr) 160 if match: 161 charset = match.group(1) 162 break 163 164 before = [to_unicode(l.rstrip('\n'), charset) 165 for l in lines[lbound:lineno]] 166 line = to_unicode(lines[lineno].rstrip('\n'), charset) 167 after = [to_unicode(l.rstrip('\n'), charset) \ 168 for l in lines[lineno + 1:ubound]] 169 159 170 return before, line, after 160 171 finally: 161 172 fileobj.close()
