How to fix this code
"John P. Rouillard" <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi all:
I managed to crash roundup in this section of code at line 1724 of
roundup/hyperdb.py:
def __getattr__(self, name):
if name in self.__dict__:
return self.__dict__[name]
try:
return self.cl.get(self.nodeid, name)
except KeyError as value:
# we trap this but re-raise it as AttributeError - all other
# exceptions should pass through untrapped
pass
# nope, no such attribute
raise AttributeError(str(value))
I am getting an:
UnboundLocalError: local variable 'value' referenced before assignment
when I pass an invalid property/name to the function. My guess is
value's scope is only in the scope of the exception code and the raise
is outside the scope.
From the comments it looks like it should be:
def __getattr__(self, name):
if name in self.__dict__:
return self.__dict__[name]
try:
return self.cl.get(self.nodeid, name)
except KeyError as value:
# we trap this but re-raise it as AttributeError - all other
# exceptions should pass through untrapped
# nope, no such attribute raise AttributeError(str(value))
pass
but I am not sure. Ideas?
--
-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.