jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/620007 )

Change subject: [4.0] Deprecate tools.UnicodeType and remove it from scripts
......................................................................

[4.0] Deprecate tools.UnicodeType and remove it from scripts

Change-Id: I49e675538160655da026d28706f9ef2f3a002884
---
M pywikibot/tools/__init__.py
M scripts/interwiki.py
M scripts/weblinkchecker.py
3 files changed, 13 insertions(+), 13 deletions(-)

Approvals:
  Matěj Suchánek: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index ade4522..ef7ae0f 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -36,7 +36,6 @@
 PYTHON_VERSION = sys.version_info[:3]
 PY2 = (PYTHON_VERSION[0] == 2)
 StringTypes = (str, bytes)
-UnicodeType = str

 try:
     import bz2
@@ -1858,3 +1857,5 @@
                              since='20200712', future_warning=True)
 wrapper._add_deprecated_attr('ArgSpec', inspect.ArgSpec,
                              since='20200712', future_warning=True)
+wrapper._add_deprecated_attr('UnicodeType', str,
+                             since='20200813', future_warning=True)
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 2c116a0..4ed77c1 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -353,7 +353,7 @@

 from pywikibot.bot import ListOption, StandardOption
 from pywikibot.cosmetic_changes import moved_links
-from pywikibot.tools import first_upper, UnicodeType
+from pywikibot.tools import first_upper
 from pywikibot.tools.formatter import color_format

 docuReplacements = {
@@ -1155,7 +1155,7 @@
             # todo list.

             if not page.exists():
-                self.conf.remove.append(UnicodeType(page))
+                self.conf.remove.append(str(page))
                 self.conf.note('{} does not exist. Skipping.'.format(page))
                 if page == self.originPage:
                     # The page we are working on is the page that does not
@@ -1214,7 +1214,7 @@
             # must be behind the page.isRedirectPage() part
             # otherwise a redirect error would be raised
             elif page_empty_check(page):
-                self.conf.remove.append(UnicodeType(page))
+                self.conf.remove.append(str(page))
                 self.conf.note('{} is empty. Skipping.'.format(page))
                 if page == self.originPage:
                     for site, count in self.todo.siteCounts():
@@ -1359,7 +1359,7 @@
             if page2 is None:
                 pywikibot.output(' ' * indent + 'Given as a hint.')
             else:
-                pywikibot.output(' ' * indent + UnicodeType(page2))
+                pywikibot.output(' ' * indent + str(page2))

     def assemble(self):
         """Assemble language links."""
@@ -1694,7 +1694,7 @@
                 # put it to new means don't delete it
                 if (
                     not self.conf.cleanup
-                    or UnicodeType(rmPage) not in self.conf.remove
+                    or str(rmPage) not in self.conf.remove
                 ):
                     new[rmsite] = rmPage
                     pywikibot.warning(
@@ -2173,7 +2173,7 @@
         # Use an extended format for the string linking to all added pages.

         def fmt(d, site):
-            return UnicodeType(d[site])
+            return str(d[site])
     else:
         # Use short format, just the language code

@@ -2358,7 +2358,7 @@
         elif len(namespaces) == 1:
             ns = namespaces[0]
             if ns != 'all':
-                if isinstance(ns, UnicodeType) or isinstance(ns, str):
+                if isinstance(ns, str):
                     index = site.namespaces.lookup_name(ns)
                     if index is None:
                         raise ValueError('Unknown namespace: ' + ns)
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index f81a34e..9b5e9de 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -137,7 +137,7 @@
 from pywikibot.pagegenerators import (
     XMLDumpPageGenerator as _XMLDumpPageGenerator,
 )
-from pywikibot.tools import deprecated, PY2, UnicodeType
+from pywikibot.tools import deprecated, PY2
 from pywikibot.tools.formatter import color_format

 import requests
@@ -399,9 +399,8 @@
             self.query.encode('ascii')
         except UnicodeEncodeError:
             encoding = self.getEncodingUsedByServer()
-            self.path = UnicodeType(urllib.quote(self.path.encode(encoding)))
-            self.query = UnicodeType(urllib.quote(self.query.encode(encoding),
-                                                  '=&'))
+            self.path = urllib.quote(self.path.encode(encoding))
+            self.query = urllib.quote(self.query.encode(encoding), '=&')

     def resolveRedirect(self, useHEAD=False):
         """
@@ -488,7 +487,7 @@
             # wrong or a pair (errno, string) representing an error
             # returned by a system call, similar to the value
             # accompanying os.error
-            if isinstance(error, UnicodeType):
+            if isinstance(error, str):
                 msg = error
             else:
                 try:

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/620007
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: I49e675538160655da026d28706f9ef2f3a002884
Gerrit-Change-Number: 620007
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to