[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] [patch] better error reporting on state
From: |
Christian Vest Hansen |
Subject: |
Re: [Fab-user] [patch] better error reporting on state |
Date: |
Thu, 21 May 2009 10:36:06 +0200 |
Why did you turn the if..else into a try..except ?
On Thu, May 21, 2009 at 5:00 AM, Jorge Vargas <address@hidden> wrote:
> I'm sorry I'm a git noob and I still don't know how it works... Why
> can't it be more predictable like mercurial :p
>
> This is a tiny patch to provide a better implementation for
> __getattr__ it will produce a more obvious error message.
>
> diff --git a/fabric/state.py b/fabric/state.py
> index 270f56f..a1f3600 100644
> --- a/fabric/state.py
> +++ b/fabric/state.py
> @@ -58,10 +58,11 @@ class _AttributeDict(dict):
>
> """
> def __getattr__(self, key):
> - if key in self:
> + try:
> return self[key]
> - else:
> - raise AttributeError # to conform with __getattr__ spec
> + except KeyError:
> + # to conform with __getattr__ spec
> + raise AttributeError(key)
>
> def __setattr__(self, key, value):
> self[key] = value
>
> Last thread for the day :p
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.