mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-11874: fix assertion failure in argparse metavar handling (GH-1826)
- bugfix and test for fragile metavar handling in argparse (see bpo-24089, bpo-14046, bpo-25058, bpo-11874) - also fixes some incorrect tests that did not make 1-element tuples correctly
This commit is contained in:
		
							parent
							
								
									ff6c077292
								
							
						
					
					
						commit
						66f02aa32f
					
				
					 3 changed files with 40 additions and 10 deletions
				
			
		|  | @ -327,7 +327,11 @@ def _format_usage(self, usage, actions, groups, prefix): | |||
|             if len(prefix) + len(usage) > text_width: | ||||
| 
 | ||||
|                 # break usage into wrappable parts | ||||
|                 part_regexp = r'\(.*?\)+|\[.*?\]+|\S+' | ||||
|                 part_regexp = ( | ||||
|                     r'\(.*?\)+(?=\s|$)|' | ||||
|                     r'\[.*?\]+(?=\s|$)|' | ||||
|                     r'\S+' | ||||
|                 ) | ||||
|                 opt_usage = format(optionals, groups) | ||||
|                 pos_usage = format(positionals, groups) | ||||
|                 opt_parts = _re.findall(part_regexp, opt_usage) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 wim glenn
						wim glenn