Merlijn van Deen has uploaded a new change for review.

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


Change subject: Start with a fresh list in html2unicode every time
......................................................................

Start with a fresh list in html2unicode every time

def x(..., something=[]):
    something.extend([1,2,3])

means something becomes [1,2,3] on the first call, but
[1,2,3,1,2,3] on the *second* call. This meant html2unicode
got a longer list of replacements every time it is called.

This commit changes it to the standart

def x(..., something=None):
   if something is None:
       something = []

which means it's always an empty list, instead of what's left from
the last call.

Change-Id: Ie490b575a8a0cc4b5d45bbb97c0606e0fd64d4f9
---
M wikipedia.py
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat 
refs/changes/11/79811/1

diff --git a/wikipedia.py b/wikipedia.py
index 976a310..f304932 100644
--- a/wikipedia.py
+++ b/wikipedia.py
@@ -5657,13 +5657,16 @@
 
 # Utility functions for parsing page titles
 
-def html2unicode(text, ignore = []):
+def html2unicode(text, ignore = None):
     """Return text, replacing HTML entities by equivalent unicode 
characters."""
+
+    if ignore is None:
+        ignore = []
     # This regular expression will match any decimal and hexadecimal entity and
     # also entities that might be named entities.
     entityR = re.compile(
         
r'&(?:amp;)?(#(?P<decimal>\d+)|#x(?P<hex>[0-9a-fA-F]+)|(?P<name>[A-Za-z]+));')
-       
+
     ignore.extend((38,     # Ampersand (&amp;)
                    39,     # Bugzilla 24093
                    60,     # Less than (&lt;)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie490b575a8a0cc4b5d45bbb97c0606e0fd64d4f9
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to