Merlijn van Deen has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/98389


Change subject: Use bytes-based url (un)quote for py3k\n\nChange-Id: 
I6f78e4e0ab25f47558b44e7053f6b9c7e29d3c15
......................................................................

Use bytes-based url (un)quote for py3k\n\nChange-Id: 
I6f78e4e0ab25f47558b44e7053f6b9c7e29d3c15

Change-Id: I3d668c18044354c48304f151552c788cc9df2100
---
M pywikibot/page.py
1 file changed, 8 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/89/98389/1

diff --git a/pywikibot/page.py b/pywikibot/page.py
index 0de6559..759093a 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -21,8 +21,13 @@
 import logging
 import re
 import unicodedata
-import urllib
 import collections
+
+import urllib
+try:
+    from urllib.parse import quote_from_bytes, unquote_to_bytes
+except ImportError:
+    from urllib import quote as quote_from_bytes, unquote as unquote_to_bytes
 
 logger = logging.getLogger("pywiki.wiki.page")
 
@@ -167,7 +172,7 @@
             title = title.replace(u' ', u'_')
         if asUrl:
             encodedTitle = title.encode(self.site.encoding())
-            title = urllib.quote(encodedTitle)
+            title = quote_from_bytes(encodedTitle)
         if as_filename:
             # Replace characters that are not possible in file names on some
             # systems.
@@ -3527,7 +3532,7 @@
     for enc in encList:
         try:
             t = title.encode(enc)
-            t = urllib.unquote(t)
+            t = unquote_to_bytes(t)
             return unicode(t, enc)
         except UnicodeError as ex:
             if not firstException:

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d668c18044354c48304f151552c788cc9df2100
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhall...@arctus.nl>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to