mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	PyType_IsSubtype(): test tp_flags for HAVE_CLASS bit before accessing
a->tp_mro. If a doesn't have class, it's considered a subclass only of itself or of 'object'. This one fix is enough to prevent the ExtensionClass test suite from dumping core, but that doesn't say much (it's a rather small test suite). Also note that for ExtensionClass-defined types, a different subclass test may be needed. But I haven't checked whether PyType_IsSubtype() is actually used in situations where this matters -- probably it doesn't, since we also don't check for classic classes.
This commit is contained in:
		
							parent
							
								
									317e9f5ef1
								
							
						
					
					
						commit
						9478d07ee7
					
				
					 1 changed files with 3 additions and 0 deletions
				
			
		| 
						 | 
					@ -273,6 +273,9 @@ PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	PyObject *mro;
 | 
						PyObject *mro;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!(a->tp_flags & Py_TPFLAGS_HAVE_CLASS))
 | 
				
			||||||
 | 
							return b == a || b == &PyBaseObject_Type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mro = a->tp_mro;
 | 
						mro = a->tp_mro;
 | 
				
			||||||
	if (mro != NULL) {
 | 
						if (mro != NULL) {
 | 
				
			||||||
		/* Deal with multiple inheritance without recursion
 | 
							/* Deal with multiple inheritance without recursion
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue