mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	Allow encoding names to be unicode strings.
This commit is contained in:
		
							parent
							
								
									583118a535
								
							
						
					
					
						commit
						af199faa9b
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -261,6 +261,11 @@ getcodec(PyObject *self, PyObject *encoding)
 | 
			
		|||
	const MultibyteCodec *codec;
 | 
			
		||||
	const char *enc;
 | 
			
		||||
 | 
			
		||||
        if (PyUnicode_Check(encoding)) {
 | 
			
		||||
		encoding = _PyUnicode_AsDefaultEncodedString(encoding, NULL);
 | 
			
		||||
		if (encoding == NULL)
 | 
			
		||||
			return NULL;
 | 
			
		||||
	}
 | 
			
		||||
	if (!PyString_Check(encoding)) {
 | 
			
		||||
		PyErr_SetString(PyExc_TypeError,
 | 
			
		||||
				"encoding name must be a string.");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue