Revision: 6463
Author: nicdumz
Date: 2009-03-02 08:42:35 +0000 (Mon, 02 Mar 2009)
Log Message:
-----------
Any reason not to use config.console_encoding ?
Using sys.std(out|err).encoding still causes problems when output is piped. Depending on
how the next process handle the pipe, .encoding can be None.
If there's a particular reason for these to use sys.stderr.encoding, that'd be
nice to use a config variable, and test for its non-"Noneness", as we currently
do for config.console_encoding
Modified Paths:
--------------
branches/rewrite/pywikibot/exceptions.py
branches/rewrite/pywikibot/page.py
Modified: branches/rewrite/pywikibot/exceptions.py
===================================================================
--- branches/rewrite/pywikibot/exceptions.py 2009-03-02 08:20:02 UTC (rev 6462)
+++ branches/rewrite/pywikibot/exceptions.py 2009-03-02 08:42:35 UTC (rev 6463)
@@ -10,7 +10,7 @@
__version__ = '$Id$'
-import sys
+from pywikibot import config
# TODO: These are copied from wikipedia.py; not certain that all of them
# will be needed in the rewrite.
@@ -19,7 +19,7 @@
"""Wikipedia error"""
def __init__(self, arg):
try:
- self.string = arg.encode(sys.stderr.encoding, "xmlcharrefreplace")
+ self.string = arg.encode(config.console_encoding,
"xmlcharrefreplace")
except (AttributeError, TypeError):
self.string = arg.encode("ascii", "xmlcharrefreplace")
def __str__(self):
Modified: branches/rewrite/pywikibot/page.py
===================================================================
--- branches/rewrite/pywikibot/page.py 2009-03-02 08:20:02 UTC (rev 6462)
+++ branches/rewrite/pywikibot/page.py 2009-03-02 08:42:35 UTC (rev 6463)
@@ -18,7 +18,6 @@
import htmlentitydefs
import logging
import re
-import sys
import threading
import unicodedata
import urllib
@@ -214,7 +213,7 @@
def __str__(self):
"""Return a console representation of the
pagelink."""
return self.title(asLink=True, forceInterwiki=True
- ).encode(sys.stderr.encoding)
+ ).encode(config.console_encoding)
def __unicode__(self):
return self.title(asLink=True, forceInterwiki=True)
@@ -222,7 +221,7 @@
def __repr__(self):
"""Return a more complete string
representation."""
return u"%s(%s)" % (self.__class__.__name__,
- self.title().encode(sys.stderr.encoding))
+ self.title().encode(config.console_encoding))
def __cmp__(self, other):
"""Test for equality and inequality of Page objects.
Show replies by date