mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-41384: Raise TclError in tkinter.OptionMenu (GH-21601)
... when an unknown option is passed. TypeError was being raised because a 2to3 fix was missing. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
		
							parent
							
								
									52bf4706a3
								
							
						
					
					
						commit
						f1d40f941a
					
				
					 3 changed files with 7 additions and 1 deletions
				
			
		|  | @ -3965,7 +3965,7 @@ def __init__(self, master, variable, value, *values, **kwargs): | ||||||
|         if 'command' in kwargs: |         if 'command' in kwargs: | ||||||
|             del kwargs['command'] |             del kwargs['command'] | ||||||
|         if kwargs: |         if kwargs: | ||||||
|             raise TclError('unknown option -'+kwargs.keys()[0]) |             raise TclError('unknown option -'+next(iter(kwargs))) | ||||||
|         menu.add_command(label=value, |         menu.add_command(label=value, | ||||||
|                  command=_setit(variable, value, callback)) |                  command=_setit(variable, value, callback)) | ||||||
|         for v in values: |         for v in values: | ||||||
|  |  | ||||||
|  | @ -307,6 +307,10 @@ class OptionMenuTest(MenubuttonTest, unittest.TestCase): | ||||||
|     def create(self, default='b', values=('a', 'b', 'c'), **kwargs): |     def create(self, default='b', values=('a', 'b', 'c'), **kwargs): | ||||||
|         return tkinter.OptionMenu(self.root, None, default, *values, **kwargs) |         return tkinter.OptionMenu(self.root, None, default, *values, **kwargs) | ||||||
| 
 | 
 | ||||||
|  |     def test_bad_kwarg(self): | ||||||
|  |         with self.assertRaisesRegex(TclError, r"^unknown option -image$"): | ||||||
|  |             tkinter.OptionMenu(self.root, None, 'b', image='') | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| @add_standard_options(IntegerSizeTests, StandardOptionsTests) | @add_standard_options(IntegerSizeTests, StandardOptionsTests) | ||||||
| class EntryTest(AbstractWidgetTest, unittest.TestCase): | class EntryTest(AbstractWidgetTest, unittest.TestCase): | ||||||
|  |  | ||||||
|  | @ -0,0 +1,2 @@ | ||||||
|  | Raise TclError instead of TypeError when an unknown option is passed to | ||||||
|  | tkinter.OptionMenu. | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Akuli
						Akuli