|valhallasw added a comment.|
Bah. The issue is that there are too many different situations that are subtly different, but that breaks everything.
- the user uses the standard windows console. Here, we want to wrap stdout etc and use the unicode console output functions
- the user redirects the output to a file. Here, we want to write to the bytes-based interface so that we can output utf-8 (rather than the ansi charset)
- the user uses a non-standard console (pycharm, spyder, idle?). Here we probably just want to push text to the output.
- stdout/stderr are some sort of non-IO buffer (e.g. in tox). Here we also just want to push text to the output.
What happened here was that 2) was incorrectly handled (we tried to write bytes to the text buffer). My original patch fixed 2), but broke 4) (where there is no bytes buffer). Fixing 4) now seems to have broken 3).
So we need to take a step back and decide what interface win32_unicode offers. This was undefined (and unclear) before; I explicitly defined it as 'always bytes' in my patch. However, the calling functions seem to assume that it should be str, both in python 2 (i.e., bytes), and in python 3 (i.e., text). So possibly the interface of win32_unicode should be 'whatever the underlying python sys.sydout/sys.stderr is' -- bytes on py2, text on py3.
Cc: David.Mirth, gerritbot, valhallasw, Xqt, Aklapper, pywikibot-bugs-list, Wesalius, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Alchimista, Rxy
_______________________________________________ pywikibot-bugs mailing list email@example.com https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs