Bugs item #3158464, was opened at 2011-01-14 22:15
Message generated for change (Comment added) made by valhallasw
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=315846…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: category
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Daniel Barrett (djbarrett)
Assigned to: Nobody/Anonymous (nobody)
Summary: category.py add crashes on redirect
Initial Comment:
If you run "python category.py add" for a page of links, and one link is a
redirect, category.py crashes with:
Traceback (most recent call last):
File "category.py", line 1188, in ?
main()
File "category.py", line 1141, in main
bot.run()
File "category.py", line 410, in run
self.treat(page)
File "category.py", line 480, in treat
text = self.load(page)
File "category.py", line 430, in load
redirTarget = pywikibot.Page(site, arg.args[0])
NameError: global name 'site' is not defined
$ python version.py
Pywikipedia [http] trunk/pywikipedia (r8824, 2011/01/14, 06:42:24)
Python 2.4.3 (#1, Nov 11 2010, 13:30:19)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)]
config-settings:
use_api = True
use_api_login = True
unicode test: ok
----------------------------------------------------------------------
Comment By: Merlijn S. van Deen (valhallasw)
Date: 2011-01-14 23:15
Message:
--- category.py 2011-01-14 23:07:25.000000000 +0100
+++ category_new.py 2011-01-14 23:03:27.000000000 +0100
@@ -426,8 +291,8 @@
else:
pywikibot.output(u"Page %s does not exist; skipping."
% page.title(asLink=True))
- except pywikibot.IsRedirectPage:
- redirTarget = pywikibot.Page(site, arg.args[0])
+ except pywikibot.IsRedirectPage, arg:
+ redirTarget = pywikibot.Page(self.site, arg.args[0])
pywikibot.output(u"WARNING: Page %s is a redirect to %s;
skipping."
% (page.title(asLink=True),
redirTarget.title(asLink=True)))
----------------------------------------------------------------------
Comment By: Daniel Barrett (djbarrett)
Date: 2011-01-14 22:52
Message:
The problem is absent prior to -r8493, when (according to the log message)
a "new class for the Add action" was used. In this older version,
redirects are noted and ignored, instead of crashing.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=315846…