mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Marc-Andre Lemburg: support for Unicode strings; 'U' expects a Unicode
object.
This commit is contained in:
		
							parent
							
								
									5aa88f097f
								
							
						
					
					
						commit
						e826ef0a89
					
				
					 1 changed files with 23 additions and 1 deletions
				
			
		|  | @ -585,7 +585,13 @@ convertsimple1(arg, p_format, p_va) | |||
| 			        char **p = va_arg(*p_va, char **); | ||||
| 			 | ||||
| 			        if (PyString_Check(arg)) | ||||
| 				  *p = PyString_AsString(arg); | ||||
| 				    *p = PyString_AS_STRING(arg); | ||||
| 				else if (PyUnicode_Check(arg)) { | ||||
| 				    arg = PyUnicode_AsUTF8String(arg); | ||||
| 				    if (arg == NULL) | ||||
| 					return "unicode conversion error"; | ||||
| 				    *p = PyString_AS_STRING(arg); | ||||
| 				} | ||||
| 				else | ||||
| 				  return "string"; | ||||
| 				if ((int)strlen(*p) != PyString_Size(arg)) | ||||
|  | @ -625,6 +631,12 @@ convertsimple1(arg, p_format, p_va) | |||
| 				  *p = 0; | ||||
| 				else if (PyString_Check(arg)) | ||||
| 				  *p = PyString_AsString(arg); | ||||
| 				else if (PyUnicode_Check(arg)) { | ||||
| 				  arg = PyUnicode_AsUTF8String(arg); | ||||
| 				  if (arg == NULL) | ||||
| 				      return "unicode conversion error"; | ||||
| 				  *p = PyString_AS_STRING(arg); | ||||
| 				} | ||||
| 				else | ||||
| 				  return "None or string"; | ||||
| 				if (*format == '#') { | ||||
|  | @ -652,6 +664,16 @@ convertsimple1(arg, p_format, p_va) | |||
| 			break; | ||||
| 		} | ||||
| 	 | ||||
| 	case 'U': /* Unicode object */ | ||||
| 		{ | ||||
| 			PyObject **p = va_arg(*p_va, PyObject **); | ||||
| 			if (PyUnicode_Check(arg)) | ||||
| 				*p = arg; | ||||
| 			else | ||||
| 				return "unicode"; | ||||
| 			break; | ||||
| 		} | ||||
| 	 | ||||
| 	case 'O': /* object */ | ||||
| 		{ | ||||
| 			PyTypeObject *type; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum