[PATCH] Consider Size as a numeric type if creating new instance
Anne Mulhern
amulhern at redhat.com
Wed Jan 15 12:54:28 UTC 2014
----- 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.
But I agree w/ the principle of the change.
- mulhern
More information about the anaconda-patches
mailing list