Xqt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398882 )

Change subject: [doc] Print a more understandable error message
......................................................................

[doc] Print a more understandable error message

- currently type checking of the color_format text value may give the message
  "expected str got <type 'str'>" for python 2 which is a bit confusing.
- now it gives "expected <type unicode> got <type 'str'>" for python 2 and
  "expected <class 'str'> got <class 'bytes'>" in python 3 which is more
  accurate

Change-Id: Id3c07760c6c8d5ec611975c4d9d0c34a65466f7d
---
M pywikibot/tools/formatter.py
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/82/398882/1

diff --git a/pywikibot/tools/formatter.py b/pywikibot/tools/formatter.py
index 149454b..cd8b96c 100644
--- a/pywikibot/tools/formatter.py
+++ b/pywikibot/tools/formatter.py
@@ -156,7 +156,8 @@
             raise ValueError('Keyword argument(s) use valid color(s): ' +
                              '", "'.join(self.colors.intersection(kwargs)))
         if not isinstance(format_string, UnicodeType):
-            raise TypeError('expected str, got 
{0}'.format(type(format_string)))
+            raise TypeError('expected {0}, got {1}'
+                            .format(type(''), type(format_string)))
         return super(_ColorFormatter, self).vformat(format_string, args,
                                                     kwargs)
 

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

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

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

Reply via email to