jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/816838 )
Change subject: [BUGFIX] Allow Exception as parameter of pywikibot.exceptions.Error
......................................................................
[BUGFIX] Allow Exception as parameter of pywikibot.exceptions.Error
Exceptions may be parameters of Exceptions calls. You can do this
def f():
try:
1/0
except ZeroDivisionError as e:
raise RuntimeError(e)
try:
f()
except Exception as e:
print('### {} ###'.format(e))
Trying this with pywikibot.Error lead to a
TypeError: __str__ returned non-string
Therefore enable Exception as parameter of pywikibot.Error
Change-Id: Ib53dc2d53fa27d2a7d15e3e959837e00f6499e72
---
M pywikibot/exceptions.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index 2e2df94..835f25e 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -193,9 +193,9 @@
"""Pywikibot error."""
- def __init__(self, arg: str) -> None:
+ def __init__(self, arg: Union[Exception, str]) -> None:
"""Initializer."""
- self.unicode = arg
+ self.unicode = str(arg)
def __str__(self) -> str:
"""Return a string representation."""
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/816838
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib53dc2d53fa27d2a7d15e3e959837e00f6499e72
Gerrit-Change-Number: 816838
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged