[prev in list] [next in list] [prev in thread] [next in thread]
List: pywikipediabot-users
Subject: [Pywikipedia-l] SVN: [5281] branches/rewrite/pywikibot/exceptions.py
From: russblau () mayflower ! knams ! wikimedia ! org
Date: 2008-04-27 20:39:35
Message-ID: E1JqDep-00027y-ND () lily ! knams ! wikimedia ! org
[Download RAW message or body]
Revision: 5281
Author: russblau
Date: 2008-04-27 20:39:35 +0000 (Sun, 27 Apr 2008)
Log Message:
-----------
Banish UnicodeEncodeError
Modified Paths:
--------------
branches/rewrite/pywikibot/exceptions.py
Modified: branches/rewrite/pywikibot/exceptions.py
===================================================================
--- branches/rewrite/pywikibot/exceptions.py 2008-04-27 16:05:02 UTC (rev 5280)
+++ branches/rewrite/pywikibot/exceptions.py 2008-04-27 20:39:35 UTC (rev 5281)
@@ -18,7 +18,10 @@
class Error(Exception):
"""Wikipedia error"""
def __init__(self, arg):
- self.string = arg.encode(sys.stdout.encoding)
+ try:
+ self.string = arg.encode(sys.stderr.encoding, "xmlcharrefreplace")
+ except (AttributeError, TypeError):
+ self.string = arg.encode("ascii", "xmlcharrefreplace")
def __str__(self):
return self.string
_______________________________________________
Pywikipedia-l mailing list
Pywikipedia-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic