mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Revert a wrong commit.
This commit is contained in:
		
							parent
							
								
									f630dac178
								
							
						
					
					
						commit
						ace8ba8d4b
					
				
					 2 changed files with 8 additions and 15 deletions
				
			
		|  | @ -44,7 +44,6 @@ static int | ||||||
| type_set_name(PyTypeObject *type, PyObject *value, void *context) | type_set_name(PyTypeObject *type, PyObject *value, void *context) | ||||||
| { | { | ||||||
| 	PyHeapTypeObject* et; | 	PyHeapTypeObject* et; | ||||||
| 	char *name; |  | ||||||
| 
 | 
 | ||||||
| 	if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { | 	if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { | ||||||
| 		PyErr_Format(PyExc_TypeError, | 		PyErr_Format(PyExc_TypeError, | ||||||
|  | @ -56,25 +55,19 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context) | ||||||
| 			     "can't delete %s.__name__", type->tp_name); | 			     "can't delete %s.__name__", type->tp_name); | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
| 	if (PyString_Check(value)) { | 	if (PyUnicode_Check(value)) { | ||||||
| 		value = PyUnicode_FromStringAndSize(PyString_AS_STRING(value), | 		value = _PyUnicode_AsDefaultEncodedString(value, NULL); | ||||||
| 						    PyString_GET_SIZE(value)); |  | ||||||
| 		if (value == NULL) | 		if (value == NULL) | ||||||
| 			return -1; | 			return -1; | ||||||
| 		/* XXX Isn't here a refcount leak? */ |  | ||||||
| 	} | 	} | ||||||
| 	if (!PyUnicode_Check(value)) { | 	if (!PyString_Check(value)) { | ||||||
| 		PyErr_Format(PyExc_TypeError, | 		PyErr_Format(PyExc_TypeError, | ||||||
| 			     "can only assign string to %s.__name__, not '%s'", | 			     "can only assign string to %s.__name__, not '%s'", | ||||||
| 			     type->tp_name, value->ob_type->tp_name); | 			     type->tp_name, value->ob_type->tp_name); | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
| 
 | 	if (strlen(PyString_AS_STRING(value)) | ||||||
| 	name = PyUnicode_AsString(value); | 	    != (size_t)PyString_GET_SIZE(value)) { | ||||||
| 	if (name == NULL) |  | ||||||
| 		return -1; |  | ||||||
| 
 |  | ||||||
| 	if (strlen(name) != PyUnicode_GET_SIZE(value)) { |  | ||||||
| 		PyErr_Format(PyExc_ValueError, | 		PyErr_Format(PyExc_ValueError, | ||||||
| 			     "__name__ must not contain null bytes"); | 			     "__name__ must not contain null bytes"); | ||||||
| 		return -1; | 		return -1; | ||||||
|  | @ -87,7 +80,7 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context) | ||||||
| 	Py_DECREF(et->ht_name); | 	Py_DECREF(et->ht_name); | ||||||
| 	et->ht_name = value; | 	et->ht_name = value; | ||||||
| 
 | 
 | ||||||
| 	type->tp_name = name; | 	type->tp_name = PyString_AS_STRING(value); | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  | @ -1665,7 +1658,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Check arguments: (name, bases, dict) */ | 	/* Check arguments: (name, bases, dict) */ | ||||||
| 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "UO!O!:type", kwlist, | 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "SO!O!:type", kwlist, | ||||||
| 					 &name, | 					 &name, | ||||||
| 					 &PyTuple_Type, &bases, | 					 &PyTuple_Type, &bases, | ||||||
| 					 &PyDict_Type, &dict)) | 					 &PyDict_Type, &dict)) | ||||||
|  |  | ||||||
|  | @ -575,7 +575,7 @@ PyErr_NewException(char *name, PyObject *base, PyObject *dict) | ||||||
| 			goto failure; | 			goto failure; | ||||||
| 	} | 	} | ||||||
| 	/* Create a real new-style class. */ | 	/* Create a real new-style class. */ | ||||||
| 	result = PyObject_CallFunction((PyObject *)&PyType_Type, "UOO", | 	result = PyObject_CallFunction((PyObject *)&PyType_Type, "sOO", | ||||||
| 				       dot+1, bases, dict); | 				       dot+1, bases, dict); | ||||||
|   failure: |   failure: | ||||||
| 	Py_XDECREF(bases); | 	Py_XDECREF(bases); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thomas Heller
						Thomas Heller