[Cheetahtemplate-discuss] [PATCH] Prevent NameMapper from gobbling up exceptions
Brought to you by:
rtyler,
tavis_rudd
From: R. T. B. <ty...@sl...> - 2009-02-01 00:37:35
|
Howdy all, I figured I'd notify the list, I discovered another bug when hunting down one of our own issues. There was/is an error in the NameMapper code that causes objects that override __getattr__() (and potentially raise exceptions) to get swallowed up inside of NameMapper.py:_valueForName() Basically the use of hasattr(obj, key) causes getattr() to break prematurely and return False, swallowing an exception in the process. Attached is a patch that fixes this in the C version of the NameMapper module as well as the Python version. I've included a regression test written against the stock PyUnit to both exhibit the behavior and correct it. (If you're curious as to how anybody might have this error, we're using __getattr__() in some instances to provide transparent distributed cache access on objects passed in on the searchList, and there are rare occassions when cache.read() might raise, and Cheetah swallows the cache read exception) As my previous patches, I've pushed this one up into my GitHub repository of Cheetah (https://github.com/rtyler/cheetah/tree), these changes in particualr have been committed to the "next" branch if you're interested. -- Cheers, -R. Tyler Ballance Slide, Inc. |