Loading ...
Sorry, an error occurred while loading the content.

[Cheetahtemplate-discuss] [PATCH] Prevent NameMapper from gobbling up exceptions

Expand Messages
  • R. Tyler Ballance
    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
    Message 1 of 1 , Jan 31, 2009
    • 0 Attachment
      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.
    Your message has been successfully submitted and would be delivered to recipients shortly.