Edgewall Software
Modify

Opened 5 years ago

Closed 5 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 trac.util.lazy: for x decorated @lazy and not yet evaluated, del x does not raise KeyError anymore.

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.

Attachments (0)

Change History (3)

comment:1 by Peter Suter, 5 years ago

Owner: set to Peter Suter
Status: newassigned

Replying to rjollos:

I wonder if it would be a good idea to backport [13927] to 1.0-stable.

Feel free to retarget.

comment:2 by Ryan J Ollos, 5 years ago

We can probably just backport to 1.0-stable later if needed.

comment:3 by Peter Suter, 5 years ago

Resolution: fixed
Status: assignedclosed

Sounds good, thanks.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Peter Suter.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Peter Suter to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.