[PATCH] Consider Size as a numeric type if creating new instance
Vratislav Podzimek
vpodzime at redhat.com
Wed Jan 15 13:13:15 UTC 2014
On Wed, 2014-01-15 at 07:54 -0500, Anne Mulhern wrote:
>
>
>
> ----- Original Message -----
> > From: "Vratislav Podzimek" <vpodzime at redhat.com>
> > To: anaconda-patches at lists.fedorahosted.org
> > Sent: Wednesday, January 15, 2014 2:52:40 AM
> > Subject: [PATCH] Consider Size as a numeric type if creating new instance
> >
> > We can easily create a Decimal instance from it just as for int, float and
> > the
> > others.
> >
> > Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> > ---
> > blivet/size.py | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/blivet/size.py b/blivet/size.py
> > index 0173ac6..50e644e 100644
> > --- a/blivet/size.py
> > +++ b/blivet/size.py
> > @@ -152,7 +152,7 @@ class Size(Decimal):
> > raise SizeParamsError("only specify one parameter")
> >
> > if bytes is not None:
> > - if type(bytes).__name__ in ["int", "long", "float", 'Decimal']:
> > + if type(bytes).__name__ in ["int", "long", "float", "Decimal",
> > "Size"]:
> > value = Decimal(bytes)
> > else:
> > raise ValueError("invalid value for bytes param")
> > --
> > 1.8.4.2
> >
> > _______________________________________________
> > anaconda-patches mailing list
> > anaconda-patches at lists.fedorahosted.org
> > https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> >
>
> Maybe it would be better to use isinstance(bytes, <tuple>) than type(bytes).__name__ in <list> to achieve the same effect.
Maybe. There are at least 5 ways of fixing the issue and I really have
no idea which one should be preferred.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list