mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	GH-90829: Fix empty iterable error message in min/max (#31181)
This commit is contained in:
		
							parent
							
								
									b034fd3e59
								
							
						
					
					
						commit
						0741da8d28
					
				
					 2 changed files with 11 additions and 3 deletions
				
			
		|  | @ -1155,7 +1155,11 @@ def test_max(self): | ||||||
|             max() |             max() | ||||||
| 
 | 
 | ||||||
|         self.assertRaises(TypeError, max, 42) |         self.assertRaises(TypeError, max, 42) | ||||||
|         self.assertRaises(ValueError, max, ()) |         with self.assertRaisesRegex( | ||||||
|  |             ValueError, | ||||||
|  |             r'max\(\) iterable argument is empty' | ||||||
|  |         ): | ||||||
|  |             max(()) | ||||||
|         class BadSeq: |         class BadSeq: | ||||||
|             def __getitem__(self, index): |             def __getitem__(self, index): | ||||||
|                 raise ValueError |                 raise ValueError | ||||||
|  | @ -1214,7 +1218,11 @@ def test_min(self): | ||||||
|             min() |             min() | ||||||
| 
 | 
 | ||||||
|         self.assertRaises(TypeError, min, 42) |         self.assertRaises(TypeError, min, 42) | ||||||
|         self.assertRaises(ValueError, min, ()) |         with self.assertRaisesRegex( | ||||||
|  |             ValueError, | ||||||
|  |             r'min\(\) iterable argument is empty' | ||||||
|  |         ): | ||||||
|  |             min(()) | ||||||
|         class BadSeq: |         class BadSeq: | ||||||
|             def __getitem__(self, index): |             def __getitem__(self, index): | ||||||
|                 raise ValueError |                 raise ValueError | ||||||
|  |  | ||||||
|  | @ -1814,7 +1814,7 @@ min_max(PyObject *args, PyObject *kwds, int op) | ||||||
|             maxitem = Py_NewRef(defaultval); |             maxitem = Py_NewRef(defaultval); | ||||||
|         } else { |         } else { | ||||||
|             PyErr_Format(PyExc_ValueError, |             PyErr_Format(PyExc_ValueError, | ||||||
|                          "%s() arg is an empty sequence", name); |                          "%s() iterable argument is empty", name); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nnarol
						Nnarol