jenkins-bot merged this change.
component: Deriving from tools.UnicodeMixin to BaseLink
Deleted the __str__ method in BaseLink and the if else
statement differenciating between PY2 and PY3. The
__str__ method is now being derived from UnicodeMixin
and if using PY2 the mixin class encodes to utf-8.
Bug: T223894
Change-Id: I0318ff8c106e340b4d9028a9759af2835e7941fe
---
M pywikibot/page.py
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 5fa4c69..b889df3 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -5703,7 +5703,7 @@
return self.__dict__ == other.__dict__
-class BaseLink(ComparableMixin):
+class BaseLink(UnicodeMixin, ComparableMixin):
"""
A MediaWiki link (local or interwiki).
@@ -5865,19 +5865,6 @@
return '[[%s:%s]]' % (self.site.code, title)
return '[[%s:%s:%s]]' % (self.site.family.name, self.site.code, title)
- if not PY2:
- def __str__(self):
- """Return a string representation."""
- return self.__unicode__()
- else: # PY2
- def __str__(self):
- """Return a string representation."""
- return self.__bytes__()
-
- def __bytes__(self):
- """Return a byte representation."""
- return self.astext().encode('ascii', 'backslashreplace')
-
def _cmpkey(self):
"""
Key for comparison of BaseLink objects.
To view, visit change 550385. To unsubscribe, or for help writing mail filters, visit settings.