jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[bugfix] Raise TypeError of text parameter of color_format is bytes

PyPy implementation of string.Formatter does not raise a TypeError;
do it in color_format itself.

Bug: T296830
Change-Id: I6372403f9e194354b21e11905f593cf32f0be3df
---
M pywikibot/tools/formatter.py
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/pywikibot/tools/formatter.py b/pywikibot/tools/formatter.py
index 1abbb85..26bfff2 100644
--- a/pywikibot/tools/formatter.py
+++ b/pywikibot/tools/formatter.py
@@ -5,6 +5,8 @@
# Distributed under the terms of the MIT license.
#
import math
+import platform
+
from string import Formatter
from typing import Any, Mapping, Sequence

@@ -136,4 +138,7 @@
:param text: The format template string
:return: The formatted string
"""
+ if platform.python_implementation() == 'PyPy' \
+ and isinstance(text, bytes): # T296830
+ raise TypeError("'text' parameter must be a str not bytes")
return _ColorFormatter().format(text, *args, **kwargs)

To view, visit change 742955. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6372403f9e194354b21e11905f593cf32f0be3df
Gerrit-Change-Number: 742955
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged