Eliminate default value as a mutable object
Bug #1471349 reported by
hongbin
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Magnum |
Fix Released
|
Undecided
|
Unassigned | ||
OpenStack Dashboard (Horizon) |
Fix Released
|
Wishlist
|
Timur Sufiev |
Bug Description
The default value is evaluated only once. This makes a difference when the default is a mutable object such as a list, dictionary, or instances of most classes. Magnum should follow what Python suggests: Do not to use mutable object as a default value.
Changed in horizon: | |
assignee: | Timur Sufiev (tsufiev-x) → Richard Jones (r1chardj0n3s) |
Changed in horizon: | |
assignee: | Richard Jones (r1chardj0n3s) → Timur Sufiev (tsufiev-x) |
Changed in magnum: | |
milestone: | none → mitaka-1 |
status: | Fix Committed → Fix Released |
Changed in horizon: | |
importance: | Undecided → Wishlist |
To post a comment you must log in.
Reviewed: https:/ /review. openstack. org/198465 /git.openstack. org/cgit/ openstack/ magnum/ commit/ ?id=0b9b7de79ab 96181e7ce89d0dd 4cf3e183aff9de
Committed: https:/
Submitter: Jenkins
Branch: master
commit 0b9b7de79ab9618 1e7ce89d0dd4cf3 e183aff9de
Author: Hongbin Lu <email address hidden>
Date: Fri Jul 3 18:09:28 2015 -0400
Eliminate mutable default arguments
The best practice in Python is not to use mutable object (i.e. list,
dictionary, or instances of most classes) as value of default argument.
See: https:/ /docs.python. org/2/tutorial/ controlflow. html#default- argument- values
This patch also added a hacking rule to enforce this practice.
Change-Id: I4aa8aede57d6fd 31b4b30c3f7535b 819e591165d
Closes-Bug: 1471349