projects
/
skytools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1403231
)
dbdict: on attribute access convert KeyError to AttributeError
author
Marko Kreen
<markokr@gmail.com>
Fri, 10 Feb 2012 10:13:00 +0000
(12:13 +0200)
committer
Marko Kreen
<markokr@gmail.com>
Fri, 10 Feb 2012 10:13:00 +0000
(12:13 +0200)
Otherwise it confuses some code (copy.deepcopy())
python/skytools/sqltools.py
patch
|
blob
|
blame
|
history
diff --git
a/python/skytools/sqltools.py
b/python/skytools/sqltools.py
index a6a7d9dcddf80ff9423922f7a4b9dcf8e7b8687b..f8014eb42278bccf34bbd72bc5bd6864c6d566d2 100644
(file)
--- a/
python/skytools/sqltools.py
+++ b/
python/skytools/sqltools.py
@@
-26,7
+26,10
@@
class dbdict(dict):
# obj.foo access
def __getattr__(self, k):
"Return attribute."
- return self[k]
+ try:
+ return self[k]
+ except KeyError:
+ raise AttributeError(k)
def __setattr__(self, k, v):
"Set attribute."
self[k] = v