[Pywikipedia-l] SVN: [4722] trunk/pywikipedia/catlib.py

russblau at svn.wikimedia.org russblau at svn.wikimedia.org
Mon Dec 17 13:35:49 UTC 2007


Revision: 4722
Author:   russblau
Date:     2007-12-17 13:35:43 +0000 (Mon, 17 Dec 2007)

Log Message:
-----------
Fix bug #1851933 (see http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects)

Modified Paths:
--------------
    trunk/pywikipedia/catlib.py

Modified: trunk/pywikipedia/catlib.py
===================================================================
--- trunk/pywikipedia/catlib.py	2007-12-17 11:58:19 UTC (rev 4721)
+++ trunk/pywikipedia/catlib.py	2007-12-17 13:35:43 UTC (rev 4722)
@@ -84,7 +84,7 @@
             return '[[%s]]' % titleWithSortKey
 
     def _getContentsAndSupercats(self, recurse=False, purge=False,
-                                 startFrom=None, cache=[]):
+                                 startFrom=None, cache=None):
         """
         Cache results of _parseCategory for a second call.
 
@@ -99,6 +99,8 @@
 
         This should not be used outside of this module.
         """
+        if cache is None:
+            cache = []
         if purge:
             self.completelyCached = False
         if recurse:
@@ -120,7 +122,7 @@
                         # this method recursively; therefore, do not cache
                         # them again
                         for item in subcat._getContentsAndSupercats(newrecurse,
-                                                                purge):
+                                                           purge, cache=cache):
                             if item[0] != SUPERCATEGORY:
                                 yield item
             for supercat in self.supercatCache:
@@ -141,8 +143,8 @@
                             # contents of subcategory are cached by calling
                             # this method recursively; therefore, do not cache
                             # them again
-                            for item in page._getContentsAndSupercats(newrecurse,
-                                                                  purge):
+                            for item in page._getContentsAndSupercats(
+                                             newrecurse, purge, cache=cache):
                                 if item[0] != SUPERCATEGORY:
                                     yield item
                 elif tag == SUPERCATEGORY:





More information about the Pywikipedia-l mailing list