mirror of
				https://github.com/python/cpython.git
				synced 2025-10-25 18:54:53 +00:00 
			
		
		
		
	Issue #27870: A left shift of zero by a large integer no longer attempts to allocate large amounts of memory.
This commit is contained in:
		
							parent
							
								
									4e1de16f88
								
							
						
					
					
						commit
						82a95277b8
					
				
					 3 changed files with 23 additions and 0 deletions
				
			
		|  | @ -4281,6 +4281,11 @@ long_lshift(PyObject *v, PyObject *w) | |||
|         PyErr_SetString(PyExc_ValueError, "negative shift count"); | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     if (Py_SIZE(a) == 0) { | ||||
|         return PyLong_FromLong(0); | ||||
|     } | ||||
| 
 | ||||
|     /* wordshift, remshift = divmod(shiftby, PyLong_SHIFT) */ | ||||
|     wordshift = shiftby / PyLong_SHIFT; | ||||
|     remshift  = shiftby - wordshift * PyLong_SHIFT; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Mark Dickinson
						Mark Dickinson