lazr config Section objects should prevent directly setting attributes

Bug #237827 reported by James Henstridge
4
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Curtis Hovey

Bug Description

The Section objects for the lazr config system have a __getattr__() method that exposes the the configuration items in that section.

It does not have a __setattr__() method though, so directly setting attributes on the object will add items to the section object's instance dictionary. At this point, __getattr__() will no longer be called for that item: the new value shadows whatever was previously there.

This causes even more problems when you push() a config overlay that changes the previous configuration item. This process involves copying the section objects, complete with whatever was in their instance dictionary. So it will also shadow any values that are supposedly stacked on top of it.

The problems caused by this are likely to occur a fair bit later than the original buggy code, making debugging difficult. For this reason, I think Section should have a __setattr__() method that disallows direct setting of attributes. This would make the error apparent at the point where the problem is introduced.

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

This means that will have to many call sites though. Let's do this post-1.2.6

Changed in launchpad:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
James Henstridge (jamesh) wrote :

Just to be clear, this problem is not blocking me so it scheduling isn't critical to me. What should be kept in mind though is whether others are likely to trip up with this bug at a later date.

Curtis Hovey (sinzui)
Changed in launchpad-foundations:
assignee: nobody → sinzui-is
milestone: none → 2.1.11
status: Confirmed → Fix Committed
Revision history for this message
Curtis Hovey (sinzui) wrote :

Fix released in Launchpad 2.1.11.

Changed in launchpad-foundations:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.