mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Issue #28774: Fix start/end pos in unicode_encode_ucs1().
Fix error position of the unicode error in ASCII and Latin1 encoders when a string returned by the error handler contains multiple non-encodable characters (non-ASCII for the ASCII codec, characters out of the U+0000-U+00FF range for Latin1).
This commit is contained in:
		
							parent
							
								
									726a57d45f
								
							
						
					
					
						commit
						d04d8474df
					
				
					 2 changed files with 7 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -10,6 +10,11 @@ What's New in Python 3.7.0 alpha 1
 | 
			
		|||
Core and Builtins
 | 
			
		||||
-----------------
 | 
			
		||||
 | 
			
		||||
- Issue #28774: Fix error position of the unicode error in ASCII and Latin1
 | 
			
		||||
  encoders when a string returned by the error handler contains multiple
 | 
			
		||||
  non-encodable characters (non-ASCII for the ASCII codec, characters out
 | 
			
		||||
  of the U+0000-U+00FF range for Latin1).
 | 
			
		||||
 | 
			
		||||
- Issue #28731: Optimize _PyDict_NewPresized() to create correct size dict.
 | 
			
		||||
  Improve speed of dict literal with constant keys up to 30%.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6798,7 +6798,7 @@ unicode_encode_ucs1(PyObject *unicode,
 | 
			
		|||
                    goto onError;
 | 
			
		||||
 | 
			
		||||
                /* subtract preallocated bytes */
 | 
			
		||||
                writer.min_size -= 1;
 | 
			
		||||
                writer.min_size -= newpos - collstart;
 | 
			
		||||
 | 
			
		||||
                if (PyBytes_Check(rep)) {
 | 
			
		||||
                    /* Directly copy bytes result to output. */
 | 
			
		||||
| 
						 | 
				
			
			@ -6835,7 +6835,7 @@ unicode_encode_ucs1(PyObject *unicode,
 | 
			
		|||
                            ch = PyUnicode_READ_CHAR(rep, i);
 | 
			
		||||
                            if (ch >= limit) {
 | 
			
		||||
                                raise_encode_exception(&exc, encoding, unicode,
 | 
			
		||||
                                                       pos, pos+1, reason);
 | 
			
		||||
                                                       collstart, collend, reason);
 | 
			
		||||
                                goto onError;
 | 
			
		||||
                            }
 | 
			
		||||
                            *str = (char)ch;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue