mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Fix regression in error message introduced in bpo-29951. (#2028)
* Fix regression in error message introduced in bpo-29951. * Add test. * Make the test more strong.
This commit is contained in:
		
							parent
							
								
									57161aac5e
								
							
						
					
					
						commit
						f9f1ccace3
					
				
					 2 changed files with 6 additions and 2 deletions
				
			
		|  | @ -136,6 +136,10 @@ def test_varargs2(self): | ||||||
|         msg = r"__contains__\(\) takes exactly one argument \(2 given\)" |         msg = r"__contains__\(\) takes exactly one argument \(2 given\)" | ||||||
|         self.assertRaisesRegex(TypeError, msg, {}.__contains__, 0, 1) |         self.assertRaisesRegex(TypeError, msg, {}.__contains__, 0, 1) | ||||||
| 
 | 
 | ||||||
|  |     def test_varargs3(self): | ||||||
|  |         msg = r"^from_bytes\(\) takes at most 2 positional arguments \(3 given\)" | ||||||
|  |         self.assertRaisesRegex(TypeError, msg, int.from_bytes, b'a', 'little', False) | ||||||
|  | 
 | ||||||
|     def test_varargs1_kw(self): |     def test_varargs1_kw(self): | ||||||
|         msg = r"__contains__\(\) takes no keyword arguments" |         msg = r"__contains__\(\) takes no keyword arguments" | ||||||
|         self.assertRaisesRegex(TypeError, msg, {}.__contains__, x=2) |         self.assertRaisesRegex(TypeError, msg, {}.__contains__, x=2) | ||||||
|  |  | ||||||
|  | @ -2089,13 +2089,13 @@ vgetargskeywordsfast_impl(PyObject **args, Py_ssize_t nargs, | ||||||
|     if (parser->max < nargs) { |     if (parser->max < nargs) { | ||||||
|         if (parser->max == 0) { |         if (parser->max == 0) { | ||||||
|             PyErr_Format(PyExc_TypeError, |             PyErr_Format(PyExc_TypeError, | ||||||
|                          "%200s%s takes no positional arguments", |                          "%.200s%s takes no positional arguments", | ||||||
|                          (parser->fname == NULL) ? "function" : parser->fname, |                          (parser->fname == NULL) ? "function" : parser->fname, | ||||||
|                          (parser->fname == NULL) ? "" : "()"); |                          (parser->fname == NULL) ? "" : "()"); | ||||||
|         } |         } | ||||||
|         else { |         else { | ||||||
|             PyErr_Format(PyExc_TypeError, |             PyErr_Format(PyExc_TypeError, | ||||||
|                          "%200s%s takes %s %d positional arguments (%d given)", |                          "%.200s%s takes %s %d positional arguments (%d given)", | ||||||
|                          (parser->fname == NULL) ? "function" : parser->fname, |                          (parser->fname == NULL) ? "function" : parser->fname, | ||||||
|                          (parser->fname == NULL) ? "" : "()", |                          (parser->fname == NULL) ? "" : "()", | ||||||
|                          (parser->min != INT_MAX) ? "at most" : "exactly", |                          (parser->min != INT_MAX) ? "at most" : "exactly", | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka