Opened 10 years ago
Closed 10 years ago
#12008 closed defect (fixed)
Deleting unevaluated `@lazy` attribute raises KeyError
Reported by: | Peter Suter | Owned by: | Peter Suter |
---|---|---|---|
Priority: | normal | Milestone: | 1.1.5 |
Component: | general | Version: | |
Severity: | normal | Keywords: | lazy |
Cc: | Branch: | ||
Release Notes: |
Lazy attributes can be invalidated for re-evaluation even if not evaluated yet. |
||
API Changes: |
Changed |
||
Internal Changes: |
Description
When the @lazy
decorator is used, previously evaluated attributes can be invalidated to force re-evaluation using del
.
However in case the attribute had not been previously evaluated this raises a KeyError
:
ERROR: For backward compatibility with plugin, upgrade with a `db` ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/edgewall/trac/trac/tests/env.py", line 177, in test_upgrade_legacy_participant self.assertTrue(self.env.upgrade()) File "/home/travis/build/edgewall/trac/trac/env.py", line 768, in upgrade del self.database_version File "/home/travis/build/edgewall/trac/trac/util/__init__.py", line 1151, in __delete__ del instance.__dict__[self.fn.__name__] KeyError: 'database_version'
This was previously discussed in comment:30:ticket:8172 and following.
changeset:13927 was committed to fix the broken unit test.
Replying to rjollos:
Feel free to retarget.