On Wed, 2011-04-13 at 18:52 -0400, Mike Bonnet wrote:
> On 04/13/2011 05:28 PM, James Antill wrote:
> > ---
> > yum/rpmsack.py | 60
> > +++++++++++++++++++++++++++++++++++++++++--------------
> > 1 files changed, 44 insertions(+), 16 deletions(-)
> >
> > diff --git a/yum/rpmsack.py b/yum/rpmsack.py
> > index e93df20..44678b2 100644
> > --- a/yum/rpmsack.py
> > +++ b/yum/rpmsack.py
> > @@ -37,6 +37,28 @@ import constants
> >
> > import yum.depsolve
> >
> > +def _open_no_umask(*args):
> > + """ Annoying people like to set umask's for root, which screws
> > everything
> > + up for user readable stuff. """
> > + oumask = os.umask(0777)
> > + try:
> > + ret = open(*args)
> > + except Exception, e:
> > + os.umask(oumask)
> > + raise e
>
> Why not try: finally: ?
I've almost never used finally's, but yeh it's much nicer:
def _open_no_umask(*args):
""" Annoying people like to set umask's for root, which screws everything
up for user readable stuff. """
oumask = os.umask(0777)
try:
ret = open(*args)
finally:
os.umask(oumask)
return ret
_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel