]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport gvanrossum's checkin of
authorMichael W. Hudson <mwh@python.net>
Fri, 22 Feb 2002 13:23:33 +0000 (13:23 +0000)
committerMichael W. Hudson <mwh@python.net>
Fri, 22 Feb 2002 13:23:33 +0000 (13:23 +0000)
    revision 2.54 of complexobject.c

Declare real and imag as read-only attributes.

This fixes SF bug #514858 (Gregory Smith): complex not entirely
immutable

2.2.1 Bugfix candidate!

Objects/complexobject.c

index 1ee1c546e5a35984fa10ecb9e3bf8a8bd5bd62f0..0bc388b896b5267d532e1641ec218b25c769db5d 100644 (file)
@@ -629,9 +629,9 @@ static PyMethodDef complex_methods[] = {
 };
 
 static PyMemberDef complex_members[] = {
-       {"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), 0,
+       {"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), READONLY,
         "the real part of a complex number"},
-       {"imag", T_DOUBLE, offsetof(PyComplexObject, cval.imag), 0,
+       {"imag", T_DOUBLE, offsetof(PyComplexObject, cval.imag), READONLY,
         "the imaginary part of a complex number"},
        {0},
 };