This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong complex variable being altered
Type: behavior Stage:
Components: Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: CarpeCimex, benjamin.peterson
Priority: normal Keywords:

Created on 2015-01-24 19:01 by CarpeCimex, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ComplexBug.py CarpeCimex, 2015-01-24 19:01 Python script demonstrating bug
Messages (2)
msg234631 - (view) Author: Gerrit Barrere (CarpeCimex) Date: 2015-01-24 19:01
The bug occurs on line 77 of the attached script. When I change the imaginary part of 'z' on line 77, it also changes the imaginary part of 'zload', which is supposed to remain constant.  Putting a dummy assignment 'z = z + 0' on line 76 fixes the bug.  This is all described in the comments around line 77 also.

I found this in the PyCharm IDE by putting a breakpoint just after line 77 and watching variables 'z' and 'zload'.  The function 'model()' is called repeatedly in this script, and you can see 'zload' changing every time the function is called.
msg234632 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-01-24 19:13
That's because "z" and "zload" are still referencing the same object. http://nedbatchelder.com/text/names.html
History
Date User Action Args
2022-04-11 14:58:12adminsetgithub: 67502
2015-01-24 19:13:42benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg234632

resolution: not a bug
2015-01-24 19:01:57CarpeCimexcreate