23 minutes and 50 seconds | ||
xqt | c7a12b5 Changeset → | |
[bugfix] Workaround UnicodeDecodeError on api error When an API error happens it tries to log the parameters but it fails as they are in a dict and the str and repr of a dict use the repr of each key and value. If the value is then a Page instance it gets in Python 2 bytes returned encoded with the console encoding. If then the str or repr of the dict is inserted into a unicode it must decode the bytes and uses by default ASCII which fails if the Page's title contains non-ASCII characters. This patch works around that by manually decoding the bytes in Python 2 using the console encoding whenever an API error happens but does not actually fix Page's repr method so it might still fail at other places. It assumes that the rest of the str is either also encoded using that or is encoded using ASCII and that the console encoding is a superset of ASCII. Conflicts: pywikibot/data/api.py tests/api_tests.py Bug: T66958 Change-Id: I298b7594599dd189211a8c268c7e094d042f40e6 |