On Tue, Jul 18, 2006 at 02:55:56PM -0400, Fred L. Drake, Jr. wrote: > On Tuesday 18 July 2006 14:52, Mihai Ibanescu wrote: > > Unicode might be a perfectly acceptable suggestion for others too. > > Are we still supporting builds that don't include Unicode? If so, that needs > to be considered in a patch as well.
Good point. Does the attached patch look reasonable? Thanks, Misa
--- Python-2.4.3/Lib/logging/handlers.py.nolocale 2006-07-19 12:15:46.000000000 -0400 +++ Python-2.4.3/Lib/logging/handlers.py 2006-07-19 12:16:14.000000000 -0400 @@ -44,6 +44,12 @@ DEFAULT_SOAP_LOGGING_PORT = 9023 SYSLOG_UDP_PORT = 514 +# If python was not built with unicode support, use the str function instead +# of the unicode type, and hope locale doesn't break things. + +if not hasattr(__builtins__, 'unicode'): + unicode = str + class BaseRotatingHandler(logging.FileHandler): """ Base class for handlers that rotate log files at a certain point. @@ -162,7 +168,7 @@ """ def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None): BaseRotatingHandler.__init__(self, filename, 'a', encoding) - self.when = string.upper(when) + self.when = unicode(when).upper() self.backupCount = backupCount # Calculate the real rollover interval, which is just the number of # seconds between rollovers. Also set the filename suffix used when @@ -642,10 +648,12 @@ """ We need to convert record level to lowercase, maybe this will change in the future. + We convert it to unicode first, to avoid locale from changing the + meaning of lower() and upper() """ msg = self.log_format_string % ( self.encodePriority(self.facility, - string.lower(record.levelname)), + unicode(record.levelname).lower()), msg) try: if self.unixsocket: @@ -854,7 +862,7 @@ ("GET" or "POST") """ logging.Handler.__init__(self) - method = string.upper(method) + method = unicode(method).upper() if method not in ["GET", "POST"]: raise ValueError, "method must be GET or POST" self.host = host
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com