Mutable List has wrong copy-behaviour in python2.7

Bug #1492317 reported by Bulat Gaifullin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
Medium
Bulat Gaifullin

Bug Description

The copy.copy or copy.deepcopy returns the new object that contains doubled content of original.
It causes because the class contains methods __setstate__ and __getstate__, that is used by functions copy and deepcopy.

the high-level algorithm, that is used in copy next:
save state of original object
create a new object of same type
> set saved state for new object
copy and append each element from original to second

it is root cause why the elements are duplicated.
In python2.6 the implementation of copy was different:
save state of original object
create a new object of same type
copy and append each element from original to second
> set saved state for new object

Changed in fuel:
assignee: nobody → Bulat Gaifullin (bgaifullin)
Dmitry Pyzhov (dpyzhov)
tags: added: tech-debt
Changed in fuel:
milestone: none → 8.0
Dmitry Pyzhov (dpyzhov)
Changed in fuel:
status: New → Confirmed
summary: - Mutable List has wrong copy-behaviour
+ Mutable List has wrong copy-behaviour in python2.7
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-web (master)

Fix proposed to branch: master
Review: https://review.openstack.org/220556

Changed in fuel:
status: Confirmed → In Progress
Dmitry Pyzhov (dpyzhov)
Changed in fuel:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-web (master)

Reviewed: https://review.openstack.org/220556
Committed: https://git.openstack.org/cgit/stackforge/fuel-web/commit/?id=30d9018369cf9d5972345df714e72f5357a67387
Submitter: Jenkins
Branch: master

commit 30d9018369cf9d5972345df714e72f5357a67387
Author: Bulat Gaifullin <email address hidden>
Date: Fri Sep 4 18:27:21 2015 +0300

    Copy-behaviour of MutableList fixed

    added methods __copy__ and __deepcopy__,
    those properly implements copy logic for instanses of this class.

    Change-Id: I510b903a06eaf5b7972f5cea1351b0528dd23320
    Closes-Bug: #1492317

Changed in fuel:
status: In Progress → Fix Committed
Dmitry Pyzhov (dpyzhov)
tags: added: area-python
Vladimir (vushakov)
tags: added: on-verification
Revision history for this message
Vladimir (vushakov) wrote :

Fix verified with CI test test_db_models.py::TestNodeInterfacesDbModels::test_copy_mutable_list - https://ci.fuel-infra.org/job/gate-fuel-web-py27/168/

tags: removed: on-verification
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.