Page MenuHomePhabricator fails under python 3: TypeError: can't concat bytes to str
Closed, ResolvedPublic


$ python3 makecat TEST -lang:en -family:wikipedia
Traceback (most recent call last):
  File "", line 263, in <module>
    if not main():
  File "", line 257, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "", line 121, in run_python_file
  File "./scripts/", line 224, in <module>
    'category', workingcatname.encode('ascii', 'xmlcharrefreplace') + '_exclude.txt')
TypeError: can't concat bytes to str
<class 'TypeError'>
CRITICAL: Closing network session.


Related Gerrit Patches:

Event Timeline

Dalba created this task.Apr 19 2017, 4:31 PM
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptApr 19 2017, 4:31 PM
Xqt added a subscriber: Xqt.Jul 14 2017, 8:45 PM

the problem is in or datafilepath. I think bytestrings are reqired not unicode or these os methods.

Xqt triaged this task as High priority.Jul 14 2017, 8:46 PM

workingcatname.encode('ascii', 'xmlcharrefreplace') + '_exclude.txt')
This is wrong -- workingcatname.encode('ascii', 'xmlcharrefreplace') will create a bytes object, and this cannot be concatenated with the '_exclude.txt' string.

workingcatname.encode('ascii', 'xmlcharrefreplace').decode('ascii') + '_exclude.txt'

should be OK.

Change 365449 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Don't use mixed bytestring and unicode for filename

Xqt claimed this task.Jul 15 2017, 12:55 PM

Change 365449 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Don't use mixed bytestring and unicode for filename

Xqt closed this task as Resolved.Jul 15 2017, 1:08 PM