Last modified: 2014-10-07 08:30:42 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T73399, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 71399 - imagetransfer.py has a unicode bug
imagetransfer.py has a unicode bug
Status: RESOLVED FIXED
Product: Pywikibot
Classification: Unclassified
Other scripts (Other open bugs)
core-(2.0)
All All
: Unprioritized normal
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-09-28 22:26 UTC by reza1615
Modified: 2014-10-07 08:30 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description reza1615 2014-09-28 22:26:45 UTC
imagetransfer.py has bug I run the command in below:

python pwb.py imagetransfer -family:wikipedia -lang:en 'File:John_Fowles.jpg' -tolang:fa -tofamily:wikipedia -keepname

bot shows this error:


Traceback (most recent call last):
  File "pwb.py", line 171, in <module>
    run_python_file(fn, argv, argvu)
  File "pwb.py", line 69, in run_python_file
    exec(compile(source, filename, "exec"), main_mod.__dict__)
  File "scripts/imagetransfer.py", line 341, in <module>
    main()
  File "scripts/imagetransfer.py", line 338, in main
    bot.run()
  File "scripts/imagetransfer.py", line 291, in run
    self.transferImage(imagelist[todo])
  File "scripts/imagetransfer.py", line 186, in transferImage
    description += '\n\n' + str(sourceImagePage.getFileVersionHistoryTable())
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 264: ordinal not in range(128)
<type 'exceptions.UnicodeEncodeError'>
CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort
Comment 1 reza1615 2014-09-28 22:30:53 UTC
Str() at line 186 should be removed or be after try:
Comment 2 Gerrit Notification Bot 2014-09-28 22:31:49 UTC
Change 163530 had a related patch set uploaded by XZise:
[FIX] Imagetransfer: Use Unicode history table

https://gerrit.wikimedia.org/r/163530
Comment 3 reza1615 2014-09-28 22:33:50 UTC
(In reply to Gerrit Notification Bot from comment #2)
> Change 163530 had a related patch set uploaded by XZise:
> [FIX] Imagetransfer: Use Unicode history table
> 
> https://gerrit.wikimedia.org/r/163530

also please add u before "\r\n\r\n" at

description += "\r\n\r\n" + unicode(sourceImagePage)
Comment 4 Fabian 2014-09-28 22:40:24 UTC
Afaik this is not necessary: 'foo' + u'bar' will automatically parse 'foo' as an unicode. But did you get an exception there too? I've included another solution because unicode() is not available anymore in Python 3 so I just use the formatter which automatically calls unicode.
Comment 5 Mpaa 2014-09-28 22:45:33 UTC
I think he refers to:
description += "\r\n\r\n" + unicode(sourceImagePage)
Comment 6 Fabian 2014-09-28 22:51:30 UTC
Oh yeah I thought I'd uploaded a new version of that fix which included that.
Comment 7 Fabian 2014-09-28 22:52:46 UTC
So there you go. I had corrupted the commit message so git-review wasn't going to upload it.
Comment 8 Gerrit Notification Bot 2014-09-28 22:57:18 UTC
Change 163530 merged by jenkins-bot:
[FIX] Imagetransfer: Don't use str()

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links