XZise has uploaded a new change for review.

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

Change subject: [FIX] Support changed _vformat signature of 3.5.1
......................................................................

[FIX] Support changed _vformat signature of 3.5.1

With Python 3.5.1 the signature of `Formatter._vformat` changed. This is
supporting this change and now returns the tuple if it had returned a tuple
first.

This is not deactivating the custom `_vformat` method in Python 3 because the
patch introduced that change might be backported to Python 2.7 (see also
https://bugs.python.org/issue25034).

Bug: T121684
Change-Id: I0d1e4f062882ed03dc7bb2040984a67970df6c52
---
M pywikibot/tools/formatter.py
1 file changed, 12 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/49/259549/1

diff --git a/pywikibot/tools/formatter.py b/pywikibot/tools/formatter.py
index ee34057..a571ee4 100644
--- a/pywikibot/tools/formatter.py
+++ b/pywikibot/tools/formatter.py
@@ -123,6 +123,18 @@
         @rtype: unicode
         """
         result = super(_ColorFormatter, self)._vformat(*args, **kwargs)
+        if isinstance(result, tuple):
+            additional_params = result[1:]
+            result = result[0]
+        else:
+            additional_params = tuple()
+        result = self._convert_bytes(result)
+        if additional_params:
+            result = (result, ) + additional_params
+        return result
+
+    def _convert_bytes(self, result):
+        """Convert everything into unicode."""
         if PY2 and isinstance(result, str):
             assert result == b''
             result = ''  # This is changing it into a unicode

-- 
To view, visit https://gerrit.wikimedia.org/r/259549
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0d1e4f062882ed03dc7bb2040984a67970df6c52
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to