Note that there's a few places in this patch where you may start raising a UnicodeException because before the code was either processing a str or a unicode but your exception2msg() may return either a str or a unicode.
A kitchen-based exception2msg (either using something like I sent in reply to Seth or copy and pasting code) would always return unicode or always return bytes depending on how it was written (look at kitchen.text.converters.exception_to_bytes if you want byte str instead of unicode). However, you still want to make sure that what you're feeding the new exception to is prepared to accept the new format that you're giving it. I'll give you a couple examples below: On Wed, Jan 12, 2011 at 09:58:01AM -0500, James Antill wrote: > try: > self._getTs(needTsRemove) > except yum.Errors.YumBaseError, e: > - return 1, [str(e)] > + return 1, [exception2msg(e)] > The old code here would always return a byte str. The new code may return unicode. If you get a unicode exception, it would probably be in code that attempts to catch yum.Errors.YumBaseError. > except yum.Errors.ConfigError, e: > - self.logger.critical(e) > + self.logger.critical(exception2msg(e)) > self.base.usage() > sys.exit(1) > I'm not quite sure how the logger handles conversion between unicode and str internally. You may get UnicodeErrors when using this if exception2msg() returns unicode type where the logger's internal handling was extracting the message from the exception as a byte string (exercising different code paths inside of the logger). > except yum.Errors.YumBaseError, e: > - return 1, [to_unicode(e)] > + return 1, [exception2msg(e)] > These could trigger UnicodeErrors if exception2msg returns a byte str instead of unicode. The exception would likely occur in code that attempts to catch yum.Errors.YumBaseError. -Toshio
pgpwAwuK7xchA.pgp
Description: PGP signature
_______________________________________________ Yum-devel mailing list Yum-devel@lists.baseurl.org http://lists.baseurl.org/mailman/listinfo/yum-devel