Bugs item #2629586, was opened at 2009-02-23 09:41
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2629586&group_…
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: rewrite
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: NicDumZ — Nicolas Dumazet (nicdumz)
Assigned to: Russell Blau (russblau)
Summary: TerminalHandler.emit crashes when message is a string
Initial Comment:
Sometimes self.format(record) can return a string, and this case is currently not handled.
How to trigger this behavior ?
1) modify Site.loadpageinfo() so that the error "u"loadpageinfo: Query on %s returned data on '%s' will be raised everytime.
2) run category.py move -from:nonasciititle -to:nonasciititle2
3) the loadpageinfo error will be triggered; category.py will catch this Error at top-level and will call pywikibot.logging.exception("Fatal error:")
Here, this gives :
pywikibot/scripts$ python category.py move -from:"Athlète du combiné nordique aux Jeux olympiques" -to:"Coureur du combiné nordique aux Jeux olympiques" -debug
Reading dump from category.dump.bz2
Found 1 wikipedia:fr processes running, including this one.
Traceback (most recent call last):
File ".../pywikibot/bot.py", line 95, in emit
"xmlcharrefreplace"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 671: ordinal not in range(128)
Dumping to category.dump.bz2, please wait...
I don't understand exactly how a string is returned by format(), and why a unicode message is expected, but it happens.
The stacktrace here is parcticularly cryptic. True, I'm still not used to the logging system, but I had to place manually old-fashioned "print"s everywhere to track the issue and understand what CAUSED this. :/
I have patched emit() in r6423 so it doesn't crash on a string message. However, Russ, I think that you might want to fix the source of the problem, in the logging system itself, rather than solving the effect. Feel free to revert this :)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2629586&group_…
Revision: 6422
Author: nicdumz
Date: 2009-02-23 08:15:42 +0000 (Mon, 23 Feb 2009)
Log Message:
-----------
In output(), trying to access __unicode__ builtin if object has one ( unicode(obj, encoding) does not try to, while unicode(obj) does. )
Modified Paths:
--------------
branches/rewrite/pywikibot/bot.py
Modified: branches/rewrite/pywikibot/bot.py
===================================================================
--- branches/rewrite/pywikibot/bot.py 2009-02-23 07:19:48 UTC (rev 6421)
+++ branches/rewrite/pywikibot/bot.py 2009-02-23 08:15:42 UTC (rev 6422)
@@ -144,10 +144,16 @@
## % type(text),
## level=VERBOSE
## )
- try:
- text = unicode(text, 'utf-8')
- except UnicodeDecodeError:
- text = unicode(text, 'iso8859-1')
+ if type(text) is not str:
+ # looks like text is a non-text object.
+ # Maybe it has a __unicode__ builtin ?
+ # (allows to print Page, Site...)
+ text = unicode(text)
+ else:
+ try:
+ text = unicode(text, 'utf-8')
+ except UnicodeDecodeError:
+ text = unicode(text, 'iso8859-1')
if newline:
text += u'\n'
if toStdout:
Bugs item #2629470, was opened at 2009-02-23 07:48
Message generated for change (Comment added) made by nicdumz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2629470&group_…
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: Fixed
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Missing 'REDIRECT localisation for bar- and als-wiki
Initial Comment:
There is no localisation for the als- and bar-wiki in the actual family.py (r6314) yet but
there should be a new line as follows:
redirect = {
'als': [u'WEITERLEITUNG']
'bar': [u'WEITERLEITUNG']
but 'REDIRECT' should also allowed. Otherwise Bots wouldn't recognize pages as redirect
page.
see http://bar.wikipedia.org/w/index.php?title=Lammer&action=edit
and http://als.wikipedia.org/w/index.php?title=Obernai&action=edit
see also bug request 2627537
Thanks.
<w:de:User:Xqt>
----------------------------------------------------------------------
>Comment By: NicDumZ — Nicolas Dumazet (nicdumz)
Date: 2009-02-23 08:20
Message:
fixed in r6421.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2629470&group_…
Bugs item #2629470, was opened at 2009-02-23 06:48
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2629470&group_…
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: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Missing 'REDIRECT localisation for bar- and als-wiki
Initial Comment:
There is no localisation for the als- and bar-wiki in the actual family.py (r6314) yet but
there should be a new line as follows:
redirect = {
'als': [u'WEITERLEITUNG']
'bar': [u'WEITERLEITUNG']
but 'REDIRECT' should also allowed. Otherwise Bots wouldn't recognize pages as redirect
page.
see http://bar.wikipedia.org/w/index.php?title=Lammer&action=edit
and http://als.wikipedia.org/w/index.php?title=Obernai&action=edit
see also bug request 2627537
Thanks.
<w:de:User:Xqt>
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2629470&group_…
Revision: 6420
Author: nicdumz
Date: 2009-02-23 05:29:01 +0000 (Mon, 23 Feb 2009)
Log Message:
-----------
* modifying Category.copyTo so it accepts either a category name or a Category object as a copy target
* Category.copyTo seemed to expect a formatted string as a message. Why is that? This was not documented, so I changed it in a way that it either accepts a formatted string, or uses the given message. Documented :)
Modified Paths:
--------------
branches/rewrite/pywikibot/page.py
Modified: branches/rewrite/pywikibot/page.py
===================================================================
--- branches/rewrite/pywikibot/page.py 2009-02-23 05:11:14 UTC (rev 6419)
+++ branches/rewrite/pywikibot/page.py 2009-02-23 05:29:01 UTC (rev 6420)
@@ -1416,11 +1416,16 @@
return False
return True
- def copyTo(self, catname, message):
+ def copyTo(self, cat, message):
"""
Copy text of category page to a new page. Does not move contents.
- @param catname: New category title (without namespace)
+ @param cat: New category title (without namespace) or Category object
+ @type cat: unicode or Category
+ @param message: message to use for category creation message
+ If two %s are provided in message, will be replaced
+ by (self.title, authorsList)
+ @type message: unicode
@return: True if copying was successful, False if target page
already existed.
@@ -1428,8 +1433,11 @@
# This seems far too specialized to be in the top-level framework
# move to category.py? (Although it doesn't seem to be used there,
# either)
- catname = self.site().category_namespace() + ':' + catname
- targetCat = Category(self.site(), catname)
+ if not isinstance(cat, Category):
+ cat = self.site().category_namespace() + ':' + cat
+ targetCat = Category(self.site(), cat)
+ else:
+ targetCat=cat
if targetCat.exists():
pywikibot.output(u'Target page %s already exists!'
% targetCat.title(),
@@ -1439,7 +1447,10 @@
pywikibot.output('Moving text from %s to %s.'
% (self.title(), targetCat.title()))
authors = ', '.join(self.contributingUsers())
- creationSummary = message % (self.title(), authors)
+ try:
+ creationSummary = message % (self.title(), authors)
+ except TypeError:
+ creationSummary=message
targetCat.put(self.get(), creationSummary)
return True