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,
Show replies by date