Page MenuHomePhabricator

listpages exception on Win32 Python 3
Closed, ResolvedPublic

Description

> pwb.py listpages -format:2 -grep:"Some Regexp" -transcludes:"SomeTemplate"  >mylist.txt
<Unicode redirected stdout>.write: TypeError('must be str, not bytes',)
Traceback (most recent call last):
  File "C:\Users\...\core\pwb.py", line 215, in <module>
    run_python_file(filename, argv, argvu, file_package)
  File "C:\Users\...\core\pwb.py", line 84, in run_python_file
    main_mod.__dict__)
  File ".\scripts\listpages.py", line 239, in <module>
    main()
  File ".\scripts\listpages.py", line 222, in main
    pywikibot.stdout(page_fmt.output(num=i, fmt=fmt))
  File "C:\Users\...\core\pywikibot\bot.py", line 470, in stdout
    logoutput(text, decoder, newline, STDOUT, **kwargs)
  File "C:\Users\...\core\pywikibot\bot.py", line 435, in logoutput
    logger.log(_level, text, extra=context, **kwargs)
  File "C:\Python34\lib\logging\__init__.py", line 1341, in log
    self._log(level, msg, args, **kwargs)
  File "C:\Python34\lib\logging\__init__.py", line 1409, in _log
    self.handle(record)
  File "C:\Python34\lib\logging\__init__.py", line 1419, in handle
    self.callHandlers(record)
  File "C:\Python34\lib\logging\__init__.py", line 1481, in callHandlers
    hdlr.handle(record)
  File "C:\Python34\lib\logging\__init__.py", line 853, in handle
    self.emit(record)
  File "C:\Users\...\core\pywikibot\userinterfaces\terminal_interface_base.py
", line 436, in emit
    return self.UI.output(text, targetStream=self.stream)
  File "C:\Users\...\core\pywikibot\userinterfaces\terminal_interface_base.py
", line 193, in output
    self._print(text, targetStream)
  File "C:\Users\...\core\pywikibot\userinterfaces\terminal_interface_base.py
", line 136, in _print
    self.printNonColorized(text, targetStream)
  File "C:\Users\...\core\pywikibot\userinterfaces\terminal_interface_base.py
", line 128, in printNonColorized
    targetStream.write(line)
  File "C:\Users\...\core\pywikibot\userinterfaces\win32_unicode.py", line 19
9, in write
    self._stream.write(text)
TypeError: must be str, not bytes

Event Timeline

jayvdb created this task.Jul 30 2015, 10:46 PM
jayvdb raised the priority of this task from to Needs Triage.
jayvdb updated the task description. (Show Details)
jayvdb added a project: Pywikibot.
jayvdb added a subscriber: jayvdb.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptJul 30 2015, 10:46 PM
Ssola added a subscriber: Ssola.EditedJul 30 2015, 10:51 PM
C:\Users\...\core>pwb.py version
Pywikibot: nightly/core (c224768, 2, 2015/04/13, 12:03:18, OUTDATED)
Release version: 2.0b3
httplib2 version: 0.9
  cacerts: C:\Users\...\core\externals\httplib2\python3\httplib2\cacerts.txt
    certificate test: ok
Python: 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (I
ntel)]
  unicode test: ok
PYWIKIBOT2_DIR: Not set
PYWIKIBOT2_DIR_PWB: C:\Users\...\core
PYWIKIBOT2_NO_USER_CONFIG: Not set
Config base dir: C:\Users\...\core
Usernames for family "wikipedia":
        ca: SalviBot (no sysop configured)
XZise added a subscriber: XZise.Jul 31 2015, 5:41 AM

Hmm this seems to me that forwarding is actually the problem. Can someone on Windows test pwb.py version > test_output?

(BTW to the comment above me, you could wrap the output in 3 ` to make everything code)

Xqt triaged this task as High priority.Sep 23 2018, 8:38 AM
Xqt closed this task as Resolved.Jun 20 2019, 1:17 PM
Xqt claimed this task.
Xqt added a subscriber: Xqt.

Works for me