Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa2e4c2

Browse files
committed
Declare real and imag as read-only attributes.
This fixes SF bug #514858 (Gregory Smith): complex not entirely immutable 2.2.1 Bugfix candidate!
1 parent 5ff8cb4 commit fa2e4c2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Objects/complexobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,9 @@ static PyMethodDef complex_methods[] = {
629629
};
630630

631631
static PyMemberDef complex_members[] = {
632-
{"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), 0,
632+
{"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), READONLY,
633633
"the real part of a complex number"},
634-
{"imag", T_DOUBLE, offsetof(PyComplexObject, cval.imag), 0,
634+
{"imag", T_DOUBLE, offsetof(PyComplexObject, cval.imag), READONLY,
635635
"the imaginary part of a complex number"},
636636
{0},
637637
};

0 commit comments

Comments
 (0)