mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	property_descr_get(): Fix a curious bug in the property() type: when
no get function was defined, the property's doc string was inaccessible. This was because the test for prop_get was made *before* the test for a NULL/None object argument. Also changed the property class defined in Python in a comment to test for NULL to decide between get and delete; this makes it less Python but then, assigning None to a property doesn't delete it!
This commit is contained in:
		
							parent
							
								
									6048ce95a9
								
							
						
					
					
						commit
						b75ba918d6
					
				
					 1 changed files with 5 additions and 5 deletions
				
			
		| 
						 | 
					@ -911,7 +911,7 @@ PyWrapper_New(PyObject *d, PyObject *self)
 | 
				
			||||||
	    self.__doc__ = doc
 | 
						    self.__doc__ = doc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def __get__(self, inst, type=None):
 | 
						def __get__(self, inst, type=None):
 | 
				
			||||||
	    if self.__get is None:
 | 
						    if self.__get is NULL:
 | 
				
			||||||
		raise AttributeError, "unreadable attribute"
 | 
							raise AttributeError, "unreadable attribute"
 | 
				
			||||||
	    if inst is None:
 | 
						    if inst is None:
 | 
				
			||||||
	        return self
 | 
						        return self
 | 
				
			||||||
| 
						 | 
					@ -963,14 +963,14 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	propertyobject *gs = (propertyobject *)self;
 | 
						propertyobject *gs = (propertyobject *)self;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (gs->prop_get == NULL) {
 | 
					 | 
				
			||||||
		PyErr_SetString(PyExc_AttributeError, "unreadable attribute");
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (obj == NULL || obj == Py_None) {
 | 
						if (obj == NULL || obj == Py_None) {
 | 
				
			||||||
		Py_INCREF(self);
 | 
							Py_INCREF(self);
 | 
				
			||||||
		return self;
 | 
							return self;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (gs->prop_get == NULL) {
 | 
				
			||||||
 | 
							PyErr_SetString(PyExc_AttributeError, "unreadable attribute");
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return PyObject_CallFunction(gs->prop_get, "(O)", obj);
 | 
						return PyObject_CallFunction(gs->prop_get, "(O)", obj);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue