@@ -1781,39 +1781,44 @@ property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset,
1781
1781
Py_XINCREF (fget );
1782
1782
Py_XINCREF (fset );
1783
1783
Py_XINCREF (fdel );
1784
- Py_XINCREF (doc );
1785
1784
1786
1785
Py_XSETREF (self -> prop_get , fget );
1787
1786
Py_XSETREF (self -> prop_set , fset );
1788
1787
Py_XSETREF (self -> prop_del , fdel );
1789
- Py_XSETREF (self -> prop_doc , doc );
1788
+ Py_XSETREF (self -> prop_doc , NULL );
1790
1789
Py_XSETREF (self -> prop_name , NULL );
1791
1790
1792
1791
self -> getter_doc = 0 ;
1792
+ PyObject * get_doc = NULL ;
1793
1793
1794
1794
/* if no docstring given and the getter has one, use that one */
1795
1795
if ((doc == NULL || doc == Py_None ) && fget != NULL ) {
1796
- PyObject * get_doc ;
1797
1796
int rc = _PyObject_LookupAttr (fget , & _Py_ID (__doc__ ), & get_doc );
1798
1797
if (rc <= 0 ) {
1799
1798
return rc ;
1800
1799
}
1801
- if (Py_IS_TYPE (self , & PyProperty_Type )) {
1802
- Py_XSETREF (self -> prop_doc , get_doc );
1803
- }
1804
- else {
1805
- /* If this is a property subclass, put __doc__
1806
- in dict of the subclass instance instead,
1807
- otherwise it gets shadowed by __doc__ in the
1808
- class's dict. */
1809
- int err = PyObject_SetAttr (
1810
- (PyObject * )self , & _Py_ID (__doc__ ), get_doc );
1811
- Py_DECREF (get_doc );
1812
- if (err < 0 )
1813
- return -1 ;
1814
- }
1815
1800
self -> getter_doc = 1 ;
1816
1801
}
1802
+ else {
1803
+ get_doc = doc ;
1804
+ Py_XINCREF (get_doc );
1805
+ }
1806
+
1807
+
1808
+ if (Py_IS_TYPE (self , & PyProperty_Type )) {
1809
+ Py_XSETREF (self -> prop_doc , get_doc );
1810
+ }
1811
+ else {
1812
+ /* If this is a property subclass, put __doc__
1813
+ in dict of the subclass instance instead,
1814
+ otherwise it gets shadowed by __doc__ in the
1815
+ class's dict. */
1816
+ int err = PyObject_SetAttr (
1817
+ (PyObject * )self , & _Py_ID (__doc__ ), get_doc );
1818
+ Py_XDECREF (get_doc );
1819
+ if (err < 0 )
1820
+ return -1 ;
1821
+ }
1817
1822
1818
1823
return 0 ;
1819
1824
}
0 commit comments