mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Issue #1521: on 64bit platforms, str.decode fails on very long strings.
The t# and w# formats were not correctly handled. Will backport.
This commit is contained in:
		
							parent
							
								
									be49a90eb3
								
							
						
					
					
						commit
						dafd32b730
					
				
					 3 changed files with 15 additions and 7 deletions
				
			
		|  | @ -65,13 +65,15 @@ def test_count(self, size): | ||||||
|         self.assertEquals(s.count('i'), 1) |         self.assertEquals(s.count('i'), 1) | ||||||
|         self.assertEquals(s.count('j'), 0) |         self.assertEquals(s.count('j'), 0) | ||||||
| 
 | 
 | ||||||
|     @bigmemtest(minsize=0, memuse=1) |     @bigmemtest(minsize=_2G + 2, memuse=3) | ||||||
|     def test_decode(self, size): |     def test_decode(self, size): | ||||||
|         pass |         s = '.' * size | ||||||
|  |         self.assertEquals(len(s.decode('utf-8')), size) | ||||||
| 
 | 
 | ||||||
|     @bigmemtest(minsize=0, memuse=1) |     @bigmemtest(minsize=_2G + 2, memuse=3) | ||||||
|     def test_encode(self, size): |     def test_encode(self, size): | ||||||
|         pass |         s = u'.' * size | ||||||
|  |         self.assertEquals(len(s.encode('utf-8')), size) | ||||||
| 
 | 
 | ||||||
|     @bigmemtest(minsize=_2G, memuse=2) |     @bigmemtest(minsize=_2G, memuse=2) | ||||||
|     def test_endswith(self, size): |     def test_endswith(self, size): | ||||||
|  |  | ||||||
|  | @ -12,6 +12,11 @@ What's New in Python 2.6 alpha 1? | ||||||
| Core and builtins | Core and builtins | ||||||
| ----------------- | ----------------- | ||||||
| 
 | 
 | ||||||
|  | - Issue #1521: On 64bit platforms, using PyArgs_ParseTuple with the t# of w# | ||||||
|  |   format code incorrectly truncated the length to an int, even when | ||||||
|  |   PY_SSIZE_T_CLEAN is set.  The str.decode method used to return incorrect | ||||||
|  |   results with huge strings. | ||||||
|  | 
 | ||||||
| - Issue #1402: Fix a crash on exit, when another thread is still running, and | - Issue #1402: Fix a crash on exit, when another thread is still running, and | ||||||
|   if the deallocation of its frames somehow calls the PyGILState_Ensure() / |   if the deallocation of its frames somehow calls the PyGILState_Ensure() / | ||||||
|   PyGILState_Release() functions. |   PyGILState_Release() functions. | ||||||
|  |  | ||||||
|  | @ -894,7 +894,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, | ||||||
| 		char **buffer; | 		char **buffer; | ||||||
| 		const char *encoding; | 		const char *encoding; | ||||||
| 		PyObject *s; | 		PyObject *s; | ||||||
| 		int size, recode_strings; | 		Py_ssize_t size; | ||||||
|  | 		int recode_strings; | ||||||
| 
 | 
 | ||||||
| 		/* Get 'e' parameter: the encoding name */ | 		/* Get 'e' parameter: the encoding name */ | ||||||
| 		encoding = (const char *)va_arg(*p_va, const char *); | 		encoding = (const char *)va_arg(*p_va, const char *); | ||||||
|  | @ -1144,7 +1145,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, | ||||||
| 	case 'w': { /* memory buffer, read-write access */ | 	case 'w': { /* memory buffer, read-write access */ | ||||||
| 		void **p = va_arg(*p_va, void **); | 		void **p = va_arg(*p_va, void **); | ||||||
| 		PyBufferProcs *pb = arg->ob_type->tp_as_buffer; | 		PyBufferProcs *pb = arg->ob_type->tp_as_buffer; | ||||||
| 		int count; | 		Py_ssize_t count; | ||||||
| 			 | 			 | ||||||
| 		if (pb == NULL ||  | 		if (pb == NULL ||  | ||||||
| 		    pb->bf_getwritebuffer == NULL || | 		    pb->bf_getwritebuffer == NULL || | ||||||
|  | @ -1166,7 +1167,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, | ||||||
| 	case 't': { /* 8-bit character buffer, read-only access */ | 	case 't': { /* 8-bit character buffer, read-only access */ | ||||||
| 		char **p = va_arg(*p_va, char **); | 		char **p = va_arg(*p_va, char **); | ||||||
| 		PyBufferProcs *pb = arg->ob_type->tp_as_buffer; | 		PyBufferProcs *pb = arg->ob_type->tp_as_buffer; | ||||||
| 		int count; | 		Py_ssize_t count; | ||||||
| 		 | 		 | ||||||
| 		if (*format++ != '#') | 		if (*format++ != '#') | ||||||
| 			return converterr( | 			return converterr( | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Amaury Forgeot d'Arc
						Amaury Forgeot d'Arc