Page MenuHomePhabricator

Pywikibot's upload.py doesn't like uploading images containing Unicode characters
Closed, InvalidPublic

Description

When trying to upload a file with title containing Ü without specifying a destination, upload.py gives the following error message:

$ python2 pwb.py upload.py -keep -noverify -ignorewarn "/…/BSicon hÜST.svg" narrow formations

ERROR: Traceback (most recent call last):
  File "/…/Documents/pywikibot/pywikibot/data/api.py", line 1558, in submit
    body=body, headers=headers)
  File "/…/Documents/pywikibot/pywikibot/tools/__init__.py", line 1105, in wrapper
    return obj(*__args, **__kw)
  File "/…/Documents/pywikibot/pywikibot/comms/http.py", line 279, in request
    r = fetch(baseuri, method, body, headers, **kwargs)
  File "/…/Documents/pywikibot/pywikibot/comms/http.py", line 381, in fetch
    error_handling_callback(request)
  File "/…/Documents/pywikibot/pywikibot/comms/http.py", line 297, in error_handling_callback
    raise request.data
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 884: ordinal not in range(128)

Event Timeline

Xqt triaged this task as Medium priority.Sep 10 2017, 11:28 AM

A python 2 issue? I could not reproduce with python 3.

It works with Python 3. Should this still be fixed or would it not be worth the time?

It works with Python 3. Should this still be fixed or would it not be worth the time?

Pywikibot does support Python 2, it should be fixed.

It works for me under Python 2

@Dvorapa, what operating system were you using? I installed Python 2.7 with Homebrew on macOS.

@Jc86035, Looking at the traceback I can tell that you're not using the latest version of pywikibot from the master branch. Could you update to the latest version and try again?

This comment has been deleted.

It works. I last updated pywikibot in April so this was probably a contributing factor.

It works. I last updated pywikibot in April so this was probably a contributing factor.

FYI, you can print usefull informations that you can copy/paste in your bugs reports by using python pwb.py version :)