Bugs item #1899414, was opened at 2008-02-22 09:42 Message generated for change (Comment added) made by nicdumz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1899414...
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: None Group: None Status: Closed Resolution: Invalid Priority: 5 Private: No Submitted By: Alex S.H. Lin (lin4h) Assigned to: Nobody/Anonymous (nobody) Summary: two attribute error in FreeBSD (wikipedia.py)
Initial Comment:
python interwiki.py -lang:zh -autonomous -continue
......
Updating links on page [[pms:Ucrain-a]]. WARNING: [[cu:OuÇÓÇÙÇÈÇÑÇÖÇÈ]] is either deleted or has a mismatching disambiguation state. Changes to be made: a modifica: [[gv:Yn Ookraan]] - [[gv:Yn Ookraane]] + [[gv:Yn Ookraan]]
NOTE: Performing a recursive query first to save time.... NOTE: Nothing left to do 2 NOTE: Updating live wiki... Sleeping for 4.4 seconds, 2008-02-22 01:50:31 Changing page [[pms:Ucrain-a]] Dump zh (wikipedia) saved Traceback (most recent call last): File "interwiki.py", line 1645, in ? bot.run() File "interwiki.py", line 1409, in run self.queryStep() File "interwiki.py", line 1388, in queryStep subj.finish(self) File "interwiki.py", line 976, in finish if self.replaceLinks(page, new, bot): File "interwiki.py", line 1127, in replaceLinks status, reason, data = page.put(newtext, comment = wikipedia.translate(page.site().lang, msg)[0] + mods) File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 1215, in put return self._putPage(newtext, comment, watchArticle, minorEdit, newPage, self.site().getToken(sysop = sysop), sysop = sysop) File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 1307, in _putPage if self.site().has_mediawiki_message("spamprotectiontitle")\ File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 4302, in has_mediawiki_message v = self.mediawiki_message(key) File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 4258, in mediawiki_message value = tree.textarea.string.strip() AttributeError: 'NoneType' object has no attribute 'strip'
python redirect.py double -always -lang:en
....When the code start to detect target, it return back this error.
Traceback (most recent call last): File "redirect.py", line 399, in ? main() File "redirect.py", line 395, in main bot.run() File "redirect.py", line 350, in run self.fix_double_redirects() File "redirect.py", line 271, in fix_double_redirects targetPage = newRedir.getRedirectTarget() File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 1663, in getRedirectTarget target = ex.message AttributeError: IsRedirectPage instance has no attribute 'message'
----------------------------------------------------------------------
Comment By: NicDumZ — Nicolas Dumazet (nicdumz) Date: 2008-02-22 16:17
Message: Logged In: YES user_id=1963242 Originator: NO
message attribute was introduced in python 2.5
err.args[0] should be used instead of err.message . (err[0] is working but is in fact deprecated)
----------------------------------------------------------------------
Comment By: NicDumZ — Nicolas Dumazet (nicdumz) Date: 2008-02-22 15:51
Message: Logged In: YES user_id=1963242 Originator: NO
I think that this was an issue of Python : From http://mail.python.org/pipermail/python-list/2007-January/424576.html, I got that example :
Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02) [GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
try:
... raise Exception, 'this is the error message' ... except Exception, err: ... print "result: ",err.message ... result: Traceback (most recent call last): File "<stdin>", line 4, in ? AttributeError: Exception instance has no attribute 'message'
Can anyone reproduce this ?
Since calling to err[0] is a simple workaround to avoid the err.message error, don't you think that converting all our exception.message to exception[0] would be a good idea ? (I remember seeing similar err.message bug reports, but I can't find them...)
----------------------------------------------------------------------
Comment By: Russell Blau (russblau) Date: 2008-02-22 14:41
Message: Logged In: YES user_id=855050 Originator: NO
The first error is a duplicate of bug 1898827; the second one cannot be duplicated--
import wikipedia
Checked for running processes. 1 processes currently running, including the current process.
p = wikipedia.Page(wikipedia.getSite(), "Napoleon") # on en:wiki p.getRedirectTarget()
Page{[[Napoleon I of France]]}
----------------------------------------------------------------------
Comment By: NicDumZ — Nicolas Dumazet (nicdumz) Date: 2008-02-22 14:34
Message: Logged In: YES user_id=1963242 Originator: NO
right, he commited while I posted that :)
----------------------------------------------------------------------
Comment By: Rotem Liss (rotemliss) Date: 2008-02-22 14:29
Message: Logged In: YES user_id=1327030 Originator: NO
The first problem was bug 1898827, which was fixed by russblau.
----------------------------------------------------------------------
Comment By: NicDumZ — Nicolas Dumazet (nicdumz) Date: 2008-02-22 14:20
Message: Logged In: YES user_id=1963242 Originator: NO
I believe that this would be a proper fix :
Index: wikipedia.py =================================================================== --- wikipedia.py (révision 5068) +++ wikipedia.py (copie de travail) @@ -1660,7 +1665,7 @@ except NoPage: raise except IsRedirectPage, ex: - target = ex.message + target = ex[0] if '|' in target: warnings.warn("'%s' has a | character, this makes no sense" % target, Warning) @@ -4258,9 +4264,9 @@ tree = BeautifulSoup(mwpage,
convertEntities=BeautifulSoup.HTML_ENTITIES,
parseOnlyThese=SoupStrainer("textarea")) - if tree.textarea is not None: + try: value = tree.textarea.string.strip() - else: + except AttributeError: value = None if value: self._mediawiki_messages[key.lower()] = value
----------------------------------------------------------------------
You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1899414...
pywikipedia-l@lists.wikimedia.org