@@ -1504,6 +1504,8 @@ property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset,
1504
1504
PyObject * fdel , PyObject * doc )
1505
1505
/*[clinic end generated code: output=01a960742b692b57 input=dfb5dbbffc6932d5]*/
1506
1506
{
1507
+ _Py_IDENTIFIER (__doc__ );
1508
+
1507
1509
if (fget == Py_None )
1508
1510
fget = NULL ;
1509
1511
if (fset == Py_None )
@@ -1524,32 +1526,30 @@ property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset,
1524
1526
1525
1527
/* if no docstring given and the getter has one, use that one */
1526
1528
if ((doc == NULL || doc == Py_None ) && fget != NULL ) {
1527
- _Py_IDENTIFIER (__doc__ );
1528
1529
PyObject * get_doc = _PyObject_GetAttrId (fget , & PyId___doc__ );
1529
1530
if (get_doc ) {
1530
- if (Py_TYPE (self ) == & PyProperty_Type ) {
1531
- Py_XSETREF (self -> prop_doc , get_doc );
1532
- }
1533
- else {
1534
- /* If this is a property subclass, put __doc__
1535
- in dict of the subclass instance instead,
1536
- otherwise it gets shadowed by __doc__ in the
1537
- class's dict. */
1538
- int err = _PyObject_SetAttrId ((PyObject * )self , & PyId___doc__ , get_doc );
1539
- Py_DECREF (get_doc );
1540
- if (err < 0 )
1541
- return -1 ;
1542
- }
1531
+ Py_XSETREF (self -> prop_doc , get_doc );
1543
1532
self -> getter_doc = 1 ;
1544
1533
}
1545
1534
else if (PyErr_ExceptionMatches (PyExc_Exception )) {
1546
1535
PyErr_Clear ();
1547
1536
}
1548
1537
else {
1538
+ Py_DECREF (get_doc );
1549
1539
return -1 ;
1550
1540
}
1551
1541
}
1552
1542
1543
+ /* If this is a property subclass, put __doc__ in dict of the subclass
1544
+ instance as well, otherwise it gets shadowed by __doc__ in the
1545
+ class's dict. */
1546
+ if (Py_TYPE (self ) != & PyProperty_Type ) {
1547
+ int err = _PyObject_SetAttrId ((PyObject * )self , & PyId___doc__ ,
1548
+ self -> prop_doc );
1549
+ if (err < 0 )
1550
+ return -1 ;
1551
+ }
1552
+
1553
1553
return 0 ;
1554
1554
}
1555
1555
0 commit comments