fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] [patch] better error reporting on state


From: Jorge Vargas
Subject: [Fab-user] [patch] better error reporting on state
Date: Wed, 20 May 2009 23:00:28 -0400

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]