Page MenuHomePhabricator

UnicodeDecoreError in site.getredirtarget while raising RuntimeError
Closed, ResolvedPublic

Description

>>> ????:?????? <<<
   Links to: [[????:?????? ??? ????]].
Skipping: Redirect target [[????:?????? ??? ????]] is not a redirect.


>>> ????:???????? <<<
Traceback (most recent call last):
  File "C:\pwb\core\pwb.py", line 253, in <module>
    if not main():
  File "C:\pwb\core\pwb.py", line 247, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "C:\pwb\core\pwb.py", line 120, in run_python_file
    main_mod.__dict__)
  File ".\scripts\redirect.py", line 909, in <module>
    main()
  File ".\scripts\redirect.py", line 896, in main
    bot.run()
  File ".\scripts\redirect.py", line 763, in run
    self.fix_double_redirects()
  File ".\scripts\redirect.py", line 585, in fix_double_redirects
    self.fix_1_double_redirect(redir_name)
  File ".\scripts\redirect.py", line 602, in fix_1_double_redirect
    targetPage = newRedir.getRedirectTarget()
  File "C:\pwb\core\pywikibot\page.py", line 1538, in getRedirectTarget
    return self.site.getredirtarget(self)
  File "C:\pwb\core\pywikibot\site.py", line 3024, in getredirtarget
    % title.encode(self.encoding()))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
not in range(128)
<type 'exceptions.UnicodeDecodeError'>
CRITICAL: Closing network session.

Event Timeline

Xqt created this task.Feb 8 2016, 7:43 AM
Xqt raised the priority of this task from to High.
Xqt updated the task description. (Show Details)
Xqt added a project: Pywikibot.
Xqt added a subscriber: Xqt.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptFeb 8 2016, 7:43 AM
Johsthao closed this task as a duplicate of T126250: <spam>.Feb 8 2016, 6:24 PM
matmarex reopened this task as Open.Feb 8 2016, 6:32 PM
Xqt added a comment.Mar 25 2016, 11:50 AM

using repr instead of str solves the UnicodeDecodeError (see T130909):

raise RuntimeError("getredirtarget: No 'redirects' found for page %r." % title.encode(self.encoding()))

jayvdb added a subscriber: jayvdb.Mar 25 2016, 12:13 PM

I think it should be '%s' ⅝ page

Xqt added a comment.Mar 25 2016, 7:11 PM

I think it should be '%s' ⅝ page

Without this encode/encoding stuff. I guess yes.

Xqt added a comment.Sep 3 2018, 1:15 PM

This still happens with python 2:

C:\pwb\GIT\core>py -2 pwb.py redirect -lang:tg do -simulate

Retrieving double redirect special page...
Retrieving 24 pages from wikipedia:tg.


>>> 29 Сентябр <<<
ERROR: Page [[tg:29 Сентябр]] is a circular redirect.
Skipping [[tg:29 Сентябр]].


>>> Лоиҳа:Тоҷикистон <<<

1 pages read
0 pages written
Execution time: 2 seconds
Read operation time: 2 seconds
Script terminated by exception:

ERROR: UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: o
rdinal not in range(128)
Traceback (most recent call last):
  File "pwb.py", line 253, in <module>
    if not main():
  File "pwb.py", line 246, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "pwb.py", line 115, in run_python_file
    main_mod.__dict__)
  File ".\scripts\redirect.py", line 806, in <module>
    main()
  File ".\scripts\redirect.py", line 802, in main
    bot.run()
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 1505, in run
    self.treat(page)
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 1737, in treat
    self.treat_page()
  File ".\scripts\redirect.py", line 715, in treat_page
    self.action_treat(self.current_page)
  File ".\scripts\redirect.py", line 585, in fix_1_double_redirect
    targetPage = newRedir.getRedirectTarget()
  File "C:\pwb\GIT\core\pywikibot\page.py", line 1668, in getRedirectTarget
    return self.site.getredirtarget(self)
  File "C:\pwb\GIT\core\pywikibot\site.py", line 3208, in getredirtarget
    % title.encode(self.encoding()))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal
not in range(128)
<type 'exceptions.UnicodeDecodeError'>
CRITICAL: Closing network session.

C:\pwb\GIT\core>
Xqt claimed this task.Sep 3 2018, 1:18 PM

Change 457442 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Sove UnicodeDecodeError in site.getredirtarget

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

Change 457442 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Solve UnicodeDecodeError in site.getredirtarget

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

Xqt closed this task as Resolved.Sep 3 2018, 3:40 PM