Revision: 5804
Author: nicdumz
Date: 2008-08-17 15:14:02 +0000 (Sun, 17 Aug 2008)
Log Message:
-----------
Better handling of non ascii string parameters
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-08-17 14:39:50 UTC (rev 5803)
+++ trunk/pywikipedia/wikipedia.py 2008-08-17 15:14:02 UTC (rev 5804)
@@ -1294,14 +1294,16 @@
host = self.site().hostname()
# Get the address of the page on that host.
address = self.site().put_address(self.urlname())
- if not isinstance(comment, unicode):
- raise ValueError("An unicode edit comment is expected as an argument")
# Use the proper encoding for the comment
- encodedComment = comment.encode(self.site().encoding())
- if not isinstance(text, unicode):
- raise ValueError("An unicode wikitext is expected as an argument")
+ try:
+ encodedComment = comment.encode(self.site().encoding())
+ except UnicodeDecodeError:
+ raise ValueError("An ascii string or unicode edit comment is expected as an argument")
# Encode the text into the right encoding for the wiki
- encodedText = text.encode(self.site().encoding())
+ try:
+ encodedText = text.encode(self.site().encoding())
+ except UnicodeDecodeError:
+ raise ValueError("An ascii string or unicode wikitext is expected as an argument")
predata = {
'wpSave': '1',
'wpSummary': encodedComment,
Patches item #2055939, was opened at 2008-08-17 16:07
Message generated for change (Comment added) made by nicdumz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=2055939&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: Marcin Cieslak (saperski)
Assigned to: Nobody/Anonymous (nobody)
Summary: spamprotectiontitle eq antispam label => SpamfilterError
Initial Comment:
On Polish Wikipedia, spamprotectiontitle contains "Filtr antyspamowy". This, in turn, is the same wording as used in the "wpAntispam" label.
Whenever you try to re-create a deleted page, a confirmation page contains:
<div id=
antispam-containter" style="display: none;">
<label for="wpAntispam">Filtr antyspamowy.
<b>NIE</b> wpisuj tu nic!</label> <input type="text" name="wpAntispam" id="wpAntispam" value="" />
</div>
The word "Filtr antyspamowy" matches the value of "MediaWiki:Spamprotectiontitle" and triggers the SpamfilterError case in the wikipedia._putPage.
This function checks for wpRecreate later and this code is not reached.
The attached patch puts the "wpRecreate" check first.
How to reproduce:
Create a page with a bot:
import wikipedia
site = wikipedia.getSite('pl','wikipedia')
p = wikipedia.Page(site, u"User:Miner/Test123")
p.put(open("/etc/motd").read())
As sysop delete the page. Re-run script and you get:
File "antispam.py", line 6, in <module>
p.put(open("/etc/motd").read())
File "wikipedia.py", line 1284, in put
newPage, self.site().getToken(sysop = sysop), sysop = sysop)
File "wikipedia.py", line 1421, in _putPage
raise SpamfilterError(url)
wikitest.SpamfilterError: http://pl.wikipedia.org
which is plain nonsense.
--Marcin
----------------------------------------------------------------------
>Comment By: NicDumZ Nicolas Dumazet (nicdumz)
Date: 2008-08-17 16:43
Message:
Logged In: YES
user_id=1963242
Originator: NO
Thanks for that very accurate bug report ;)
Fixed in r5803 !
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=2055939&group_…
Revision: 5803
Author: nicdumz
Date: 2008-08-17 14:39:50 +0000 (Sun, 17 Aug 2008)
Log Message:
-----------
Fixing bug "spamprotectiontitle eq antispam label => SpamfilterError"
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-08-17 07:40:05 UTC (rev 5802)
+++ trunk/pywikipedia/wikipedia.py 2008-08-17 14:39:50 UTC (rev 5803)
@@ -1396,6 +1396,9 @@
# A second text area means that an edit conflict has occured.
if 'id=\'wpTextbox2\' name="wpTextbox2"' in data:
raise EditConflict(u'An edit conflict has occured.')
+
+ # remove the wpAntispam keyword before checking for Spamfilter
+ data = re.sub(u'(?s)<label for="wpAntispam">.*?</label>', '', data)
if self.site().has_mediawiki_message("spamprotectiontitle")\
and self.site().mediawiki_message('spamprotectiontitle') in data:
try:
Patches item #2055939, was opened at 2008-08-17 16:07
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=2055939&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: Marcin Cieslak (saperski)
Assigned to: Nobody/Anonymous (nobody)
Summary: spamprotectiontitle eq antispam label => SpamfilterError
Initial Comment:
On Polish Wikipedia, spamprotectiontitle contains "Filtr antyspamowy". This, in turn, is the same wording as used in the "wpAntispam" label.
Whenever you try to re-create a deleted page, a confirmation page contains:
<div id=
antispam-containter" style="display: none;">
<label for="wpAntispam">Filtr antyspamowy.
<b>NIE</b> wpisuj tu nic!</label> <input type="text" name="wpAntispam" id="wpAntispam" value="" />
</div>
The word "Filtr antyspamowy" matches the value of "MediaWiki:Spamprotectiontitle" and triggers the SpamfilterError case in the wikipedia._putPage.
This function checks for wpRecreate later and this code is not reached.
The attached patch puts the "wpRecreate" check first.
How to reproduce:
Create a page with a bot:
import wikipedia
site = wikipedia.getSite('pl','wikipedia')
p = wikipedia.Page(site, u"User:Miner/Test123")
p.put(open("/etc/motd").read())
As sysop delete the page. Re-run script and you get:
File "antispam.py", line 6, in <module>
p.put(open("/etc/motd").read())
File "wikipedia.py", line 1284, in put
newPage, self.site().getToken(sysop = sysop), sysop = sysop)
File "wikipedia.py", line 1421, in _putPage
raise SpamfilterError(url)
wikitest.SpamfilterError: http://pl.wikipedia.org
which is plain nonsense.
--Marcin
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=2055939&group_…
Bugs item #2053373, was opened at 2008-08-15 15:53
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2053373&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: interwiki
Group: None
Status: Pending
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Yong-geun Jeong (ficell)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pybot can't recognize translated magicwords.
Initial Comment:
http://ko.wikipedia.org/?diff=2194957&oldid=2194231
Recently, magicwords were translated into Korean language. But pywikipediabot can't recognize that. Pywikipediabot adding interwiki at redirects.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2008-08-16 05:45
Message:
Logged In: NO
Yes. is Korean magicword for REDIRECT.
----------------------------------------------------------------------
Comment By: NicDumZ Nicolas Dumazet (nicdumz)
Date: 2008-08-15 16:38
Message:
Logged In: YES
user_id=1963242
Originator: NO
so if I get it right, is the ko: magic word for REDIRECT ?
I have added support for it in r5800 :)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2053373&group_…
Patches item #2033435, was opened at 2008-07-31 03:47
Message generated for change (Comment added) made by sf-robot
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=2033435&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: Woo-Jin Kim (kwj2772)
Assigned to: Nobody/Anonymous (nobody)
Summary: checkimages.py - support ko.wikipedia
Initial Comment:
I've modified checkimages.py and operating in kowikipedia.
This script will support Korean.
script source:
http://ko.wikipedia.org/wiki/%EC%82%AC%EC%9A%A9%EC%9E%90:%EA%B9%80%EC%9A%B0…
Thank you!
----------------------------------------------------------------------
>Comment By: SourceForge Robot (sf-robot)
Date: 2008-08-16 02:20
Message:
Logged In: YES
user_id=1312539
Originator: NO
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
----------------------------------------------------------------------
Comment By: NicDumZ Nicolas Dumazet (nicdumz)
Date: 2008-08-01 16:44
Message:
Logged In: YES
user_id=1963242
Originator: NO
Looks like you were using an old version ? I only added the localisation
messages in r5777, let me know if something else was needed.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=2033435&group_…
Bugs item #2053914, was opened at 2008-08-16 08:22
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=2053914&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: Albam handae (albamhandae)
Assigned to: Nobody/Anonymous (nobody)
Summary: Korean Translation
Initial Comment:
Korean Translation!
family.py :
To change " 'ko': u'Mediawiki' ", to " 'ko': u'', ".
To add " 'ko': u'', ".
("" means "Mediawiki" in English)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2053914&group_…
Bugs item #2053373, was opened at 2008-08-15 17:53
Message generated for change (Comment added) made by nicdumz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2053373&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: interwiki
Group: None
>Status: Pending
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Yong-geun Jeong (ficell)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pybot can't recognize translated magicwords.
Initial Comment:
http://ko.wikipedia.org/?diff=2194957&oldid=2194231
Recently, magicwords were translated into Korean language. But pywikipediabot can't recognize that. Pywikipediabot adding interwiki at redirects.
----------------------------------------------------------------------
>Comment By: NicDumZ Nicolas Dumazet (nicdumz)
Date: 2008-08-15 18:38
Message:
Logged In: YES
user_id=1963242
Originator: NO
so if I get it right, is the ko: magic word for REDIRECT ?
I have added support for it in r5800 :)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2053373&group_…