From 136fa6ad3d9036b9ebae4a52f5cfcf467be3a143 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 29 Apr 2016 05:22:45 +0000 Subject: Throw correct exceptions in container LazyDict container methods, not that anybody is likely to care. svn path=/branches/tk705/; revision=6405 --- potpourri/ca-unpickle.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'potpourri/ca-unpickle.py') diff --git a/potpourri/ca-unpickle.py b/potpourri/ca-unpickle.py index d49d0186..c988a168 100755 --- a/potpourri/ca-unpickle.py +++ b/potpourri/ca-unpickle.py @@ -28,15 +28,18 @@ class LazyDict(object): def __init__(self, *args, **kwargs): self._d = dict(*args, **kwargs) - def __getitem__(self, name): + def __getattr__(self, name): if name in self._d: return self._d[name] raise AttributeError - __getattr__ = __getitem__ + def __getitem__(self, name): + if name in self._d: + return self._d[name] + raise KeyError def __missing__(self, name): - raise AttributeError + raise KeyError def __iter__(self): return self._d.iterkeys() -- cgit v1.2.3