mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Changes to ctypes and Mac toolbox glue that fix test_threading and test_platform.
However, test_ctypes is still broken -- and apparently more than before.
This commit is contained in:
		
							parent
							
								
									9a63470fd7
								
							
						
					
					
						commit
						5e23d5732b
					
				
					 2 changed files with 71 additions and 20 deletions
				
			
		|  | @ -159,12 +159,32 @@ int | |||
| PyMac_GetOSType(PyObject *v, OSType *pr) | ||||
| { | ||||
| 	uint32_t tmp; | ||||
| 	if (!PyString_Check(v) || PyString_Size(v) != 4) { | ||||
| 	const char *str; | ||||
| 	int len; | ||||
| 	if (PyUnicode_Check(v)) { | ||||
| 		v = _PyUnicode_AsDefaultEncodedString(v, NULL); | ||||
| 		if (v == NULL) | ||||
| 			return 0; | ||||
| 	} | ||||
| 	if (PyString_Check(v)) { | ||||
| 		str = PyString_AS_STRING(v); | ||||
| 		len = PyString_GET_SIZE(v); | ||||
| 	} | ||||
| 	else if (PyBytes_Check(v)) { | ||||
| 		str = PyBytes_AS_STRING(v); | ||||
| 		len = PyBytes_GET_SIZE(v); | ||||
| 	} | ||||
| 	else { | ||||
| 		PyErr_SetString(PyExc_TypeError, | ||||
| 			"OSType arg must be string of 4 chars"); | ||||
| 			"OSType arg must be string (of 4 chars)"); | ||||
| 		return 0; | ||||
| 	} | ||||
| 	memcpy((char *)&tmp, PyString_AsString(v), 4); | ||||
| 	if (len != 4) { | ||||
| 		PyErr_SetString(PyExc_TypeError, | ||||
| 			"OSType arg must be (string of) 4 chars"); | ||||
| 		return 0; | ||||
| 	} | ||||
| 	memcpy((char *)&tmp, str, 4); | ||||
| 	*pr = (OSType)ntohl(tmp); | ||||
| 	return 1; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum