Page MenuHomePhabricator

UnicodeDecodeError in logger class
Closed, ResolvedPublic


After this commit I have an issue with running function containing unicode strings with non-ascii characters if 'site' property is not explicitly defined.

Say, this code

# -*- coding: utf-8 -*-
import pywikibot

site = pywikibot.getSite('ru', 'wikipedia')

r ='purge', titles=u'Россия')


Traceback (most recent call last):
  File "", line 6, in <module>
    r ='purge', titles=u'Россия')
  File "/shared/pywikipedia/core/pywikibot/data/", line 1108, in __init__
    warn('Request() invoked without a site', RuntimeWarning, 2)
  File "/usr/lib/python2.7/logging/", line 1713, in _showwarning
    logger.warning("%s", s)
  File "/usr/lib/python2.7/logging/", line 1164, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "/usr/lib/python2.7/logging/", line 1271, in _log
  File "/usr/lib/python2.7/logging/", line 1281, in handle
  File "/usr/lib/python2.7/logging/", line 1321, in callHandlers
  File "/usr/lib/python2.7/logging/", line 749, in handle
  File "/shared/pywikipedia/core/pywikibot/userinterfaces/", line 494, in emit
    ('warn(', 'exceptions.', 'Warning)', 'Warning,'))
  File "/shared/pywikipedia/core/pywikibot/userinterfaces/", line 493, in <genexpr>
    s in msg for s in
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 118: ordinal not in range(128)
<type 'exceptions.UnicodeDecodeError'>

Event Timeline

korzhimanov raised the priority of this task from to Needs Triage.
korzhimanov updated the task description. (Show Details)
korzhimanov added a project: Pywikibot-compat.
korzhimanov added a subscriber: korzhimanov.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptMay 13 2015, 11:37 AM
XZise added a subscriber: XZise.

Hmm seems that the message is bytes in Python 2.

XZise set Security to None.

Change 210681 had a related patch set uploaded (by XZise):
[FIX] TerminalHandler: Expect str in Python 2

Change 210681 merged by jenkins-bot:
[FIX] TerminalHandler: Expect str in Python 2