Ticket #408 (closed defect: fixed)
_object_stack() causes exception if proxy object never had a "push"
| Reported by: | rcscomp | Owned by: | ianb |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | paste | Version: | released-version |
| Severity: | normal | Keywords: | |
| Cc: | randy@… |
Description
class TestRegistryHasObject(object):
testsop = StackedObjectProxy(name="testsop")
def test_registry(self):
assert not registry_has_object(self.testsop)
foo = ''
self.testsop._push_object(foo)
assert registry_has_object(self.testsop)
self.testsop._pop_object()
assert not registry_has_object(self.testsop)
This should work, but the first assert throws an exception.
Looking at the code indicates that the following would solve the problem at hand (but it may be better to initialize the ____local__ with .objects instead of catching the exception:
def _object_stack(self):
"""Returns all of the objects stacked in this container
(Might return [] if there are none)
"""
try:
return self.____local__.objects[:]
except AssertionError:
return []
except AttributeError, e:
if "object has no attribute 'objects'" not in str(e):
raise
return []
Change History
Note: See
TracTickets for help on using
tickets.
