@@ -1585,18 +1585,22 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
1585
1585
1586
1586
propertyobject * gs = (propertyobject * )self ;
1587
1587
if (gs -> prop_get == NULL ) {
1588
- if (gs -> prop_name != NULL ) {
1588
+ PyObject * qualname = PyType_GetQualName (Py_TYPE (obj ));
1589
+ if (gs -> prop_name != NULL && qualname != NULL ) {
1589
1590
PyErr_Format (PyExc_AttributeError ,
1590
1591
"property %R of %R object has no getter" ,
1591
1592
gs -> prop_name ,
1592
- PyType_GetQualName ( Py_TYPE ( obj )) );
1593
+ qualname );
1593
1594
}
1594
- else {
1595
+ else if ( qualname != NULL ) {
1595
1596
PyErr_Format (PyExc_AttributeError ,
1596
1597
"property of %R object has no getter" ,
1597
- PyType_GetQualName (Py_TYPE (obj )));
1598
+ qualname );
1599
+ } else {
1600
+ PyErr_SetString (PyExc_AttributeError ,
1601
+ "property has no getter" );
1598
1602
}
1599
-
1603
+ Py_XDECREF ( qualname );
1600
1604
return NULL ;
1601
1605
}
1602
1606
@@ -1617,27 +1621,32 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value)
1617
1621
}
1618
1622
1619
1623
if (func == NULL ) {
1620
- if (gs -> prop_name != NULL && obj != NULL ) {
1624
+ PyObject * qualname = NULL ;
1625
+ if (obj != NULL ) {
1626
+ qualname = PyType_GetQualName (Py_TYPE (obj ));
1627
+ }
1628
+ if (gs -> prop_name != NULL && qualname != NULL ) {
1621
1629
PyErr_Format (PyExc_AttributeError ,
1622
1630
value == NULL ?
1623
1631
"property %R of %R object has no deleter" :
1624
1632
"property %R of %R object has no setter" ,
1625
1633
gs -> prop_name ,
1626
- PyType_GetQualName ( Py_TYPE ( obj )) );
1634
+ qualname );
1627
1635
}
1628
- else if (obj != NULL ) {
1636
+ else if (qualname != NULL ) {
1629
1637
PyErr_Format (PyExc_AttributeError ,
1630
1638
value == NULL ?
1631
1639
"property of %R object has no deleter" :
1632
1640
"property of %R object has no setter" ,
1633
- PyType_GetQualName ( Py_TYPE ( obj )) );
1641
+ qualname );
1634
1642
}
1635
1643
else {
1636
1644
PyErr_SetString (PyExc_AttributeError ,
1637
1645
value == NULL ?
1638
1646
"property has no deleter" :
1639
1647
"property has no setter" );
1640
1648
}
1649
+ Py_XDECREF (qualname );
1641
1650
return -1 ;
1642
1651
}
1643
1652
0 commit comments