Fix instances of functions using a mutable list as a default param value
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Object Storage (swift) |
Fix Released
|
Undecided
|
Brian Cline |
Bug Description
In at least the object replicator (swift/
In Python, this is an issue since functions are treated as objects that can maintain state between calls. As a result, this only gets set once, and it's possible for it to stack list values over time in cases when you might expect them to be empty. Depending on use, this can cause incredibly complex and yet very subtle bugs in code that reads just fine (at least once you've digested the incredibly high density of some of this codebase ;-).
There are no comments in the code I've seen, however, indicating that this usage is meant specifically to take advantage of this subtlety in the language. We'd definitely want to document that if it is the case.
Here's some additional information explaining this behavior in Python:
http://
http://
Wanted to create this as a discussion point if needed, and as a courtesy to attach it to the patch I'm going to push in a few minutes. Very curious to see whether or not the tests are affected at all by a correction.
Changed in swift: | |
assignee: | nobody → Brian Cline (briancline) |
status: | New → In Progress |
Changed in swift: | |
milestone: | none → 1.9.0 |
Changed in swift: | |
status: | Fix Committed → Fix Released |
Fix proposed to branch: master /review. openstack. org/27825
Review: https:/