[Pywikipedia-l] SVN: [6604] trunk/pywikipedia/interwiki.py

nicdumz at svn.wikimedia.org nicdumz at svn.wikimedia.org
Tue Apr 14 16:05:46 UTC 2009


Revision: 6604
Author:   nicdumz
Date:     2009-04-14 16:05:46 +0000 (Tue, 14 Apr 2009)

Log Message:
-----------
[1783487] "Interwiki crash on deleted page" :
getting the pagetext before, to avoid raising exceptions.
If (race condition) the page gets deleted in between,
an EditConflict Error will be raised later on save.

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

Modified: trunk/pywikipedia/interwiki.py
===================================================================
--- trunk/pywikipedia/interwiki.py	2009-04-14 06:00:54 UTC (rev 6603)
+++ trunk/pywikipedia/interwiki.py	2009-04-14 16:05:46 UTC (rev 6604)
@@ -1174,8 +1174,9 @@
             # This is not a page, but a subpage. Do not edit it.
             wikipedia.output(u"Not editing %s: not doing interwiki on subpages" % page.aslink(True))
             raise SaveError
-
-        if not page.exists():
+        try:
+            pagetext = page.get()
+        except wikipedia.NoPage:
             wikipedia.output(u"Not editing %s: page does not exist" % page.aslink(True))
             raise SaveError
 
@@ -1186,7 +1187,7 @@
         new = dict(newPages)
 
         # remove interwiki links to ignore
-        for iw in re.finditer('<!-- *\[\[(.*?:.*?)\]\] *-->', page.get()):
+        for iw in re.finditer('<!-- *\[\[(.*?:.*?)\]\] *-->', pagetext):
             try:
                 ignorepage = wikipedia.Page(page.site(), iw.groups()[0])
             except (wikipedia.NoSuchSite, wikipedia.InvalidTitle):





More information about the Pywikipedia-l mailing list