Page MenuHomePhabricator

UnicodeEncodeError in profiling script report.py
Closed, ResolvedPublic

Description

Given URL gives incomplete output, ending with the following error report:

dbg = 0, comparedformat = '\n<tr class="data"><td class="name">%s</td>\n<td>%...td><td>%.1f</td><td>%.1f</td><td>%.1f</td>\n</tr>\n', name = u'MessageCache::get-accesskey-n-\u304a\u77e5\u3089\u305b', name.replace = <built-in method replace of unicode object>, event = {'count': 1220, 'cpu': 0.074995999999999993, 'cpusq': 0.00052499999999999997, 'onecpu': 6.1472131147540985e-05, 'onereal': 8.372131147540983e-05, 'real': 0.10213999999999999, 'realsq': 6.4999999999999994e-05}, callcount = 4.7277100580675178e-05, countdiff = 0, realpct = 1.9333504993955514e-08, realpctdiff = 0, onereal = 8.372131147540983e-05, onerealdiff = 0

UnicodeEncodeError: 'ascii' codec can't encode characters in position 65-68: ordinal not in range(128)

args = ('ascii', u'\n<tr class="data"><td class="name">MessageCache:...0</td><td>0.0</td><td>0.1</td><td>0.0</td>\n</tr>\n', 65, 69, 'ordinal not in range(128)') 
encoding = 'ascii' 
end = 69 
object = u'\n<tr class="data"><td class="name">MessageCache:...0</td><td>0.0</td><td>0.1</td><td>0.0</td>\n</tr>\n' 
reason = 'ordinal not in range(128)' 
start = 65

Version: unspecified
Severity: normal
URL: http://noc.wikimedia.org/cgi-bin/report.py?db=1.23wmf7&sort=count&limit=5000&sample=&compare=&prefix=MessageCache::get

Details

Reference
bz16716

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:25 PM
bzimport set Reference to bz16716.

Looks like the script needs to be told to output UTF-8, otherwise Python's defaulting to ASCII and it barfs on some of the print statements...

http://svn.wikimedia.org/viewvc/mediawiki/trunk/udpprofile/web/report.py?view=markup

Tim temporarily fixed this by using try/except so that the lines with issues are skipped. Will be overwritten by puppet.

Maybe Asher knows how to get report.py to behave?

Change 104159 had a related patch set uploaded by Ori.livneh:
Make report.py set the default system encoding to UTF-8

https://gerrit.wikimedia.org/r/104159

Change 104159 merged by Ori.livneh:
Make report.py set the default system encoding to UTF-8

https://gerrit.wikimedia.org/r/104159

Thanks for the fix! Nice surprise after 5 years :).

URL gives Permission denied now.