[Yum-devel] [PATCH] YumRPMTransError: "errors" should not end up in e.value. BZ 966372

James Antill james at fedoraproject.org
Tue May 28 13:35:52 UTC 2013

On Fri, 2013-05-24 at 04:35 -0400, Zdenek Pavlas wrote:
> >  As always the big problem is that this is a significant API change for
> > yum, so we'd need to somehow audit every piece of code that ever used
> > yum and make sure this doesn't affect them negatively.
> >  I'd guess that it probably doesn't, but it's much easier to just know
> > it doesn't because we didn't API break anything.
> I understand this.  Found only one user of this in Yum,
> and it's not likely used by any plugin.

 Yeh, but it's hard to impossible to say for sure.

> > > reproducer:
> > > >>> e = yum.Errors.YumRPMTransError('Foo', [])
> > > >>> yum.i18n.exception2msg(e.value)
> > 
> >  Why call exception2msg(e.value) ? Does any code actually do that?
> >  exception2msg(e) works, right?
>     def exFatal(e):
>         logger.critical('\n\n%s', exception2msg(e.value))
>         if unlock(): return 200
>         return 1
> Here it's probably a (another) bug, should be exception2msg(e)

 Yeh, that looks like a bug.

> , but
> exception2msg() getattrs value first, too:
> def exception2msg(e):
>     try:
>         return to_unicode(e.value)
>     ...
> to_unicode() simply returns the arg when it's a list.  And I'd rather
> not touch this, since exception2msg() and to_unicode() are used a lot.

 Ugh, not sure if this was a great idea. At the least we should probably
check to see if e.value is a string type, and move onto unicode(e) if

 IIRC the problem we were trying to workaround by using e.value first
here was that unicode(e) doesn't work on RHEL-5 python, so we could
maybe remove that part of exception2msg() now.

More information about the Yum-devel mailing list