mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-33422: Fix quotation marks getting deleted when looking up byte/string literals on pydoc. (GH-6701)
Also update the list of string prefixes.
This commit is contained in:
		
							parent
							
								
									c4994dc00d
								
							
						
					
					
						commit
						b2043bbe60
					
				
					 2 changed files with 11 additions and 2 deletions
				
			
		
							
								
								
									
										11
									
								
								Lib/pydoc.py
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								Lib/pydoc.py
									
										
									
									
									
								
							|  | @ -1747,8 +1747,9 @@ class Helper: | ||||||
|     } |     } | ||||||
|     # Either add symbols to this dictionary or to the symbols dictionary |     # Either add symbols to this dictionary or to the symbols dictionary | ||||||
|     # directly: Whichever is easier. They are merged later. |     # directly: Whichever is easier. They are merged later. | ||||||
|  |     _strprefixes = [p + q for p in ('b', 'f', 'r', 'u') for q in ("'", '"')] | ||||||
|     _symbols_inverse = { |     _symbols_inverse = { | ||||||
|         'STRINGS' : ("'", "'''", "r'", "b'", '"""', '"', 'r"', 'b"'), |         'STRINGS' : ("'", "'''", '"', '"""', *_strprefixes), | ||||||
|         'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&', |         'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&', | ||||||
|                        '|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'), |                        '|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'), | ||||||
|         'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'), |         'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'), | ||||||
|  | @ -1910,7 +1911,13 @@ def interact(self): | ||||||
|                 if not request: break |                 if not request: break | ||||||
|             except (KeyboardInterrupt, EOFError): |             except (KeyboardInterrupt, EOFError): | ||||||
|                 break |                 break | ||||||
|             request = replace(request, '"', '', "'", '').strip() |             request = request.strip() | ||||||
|  | 
 | ||||||
|  |             # Make sure significant trailing quoting marks of literals don't | ||||||
|  |             # get deleted while cleaning input | ||||||
|  |             if (len(request) > 2 and request[0] == request[-1] in ("'", '"') | ||||||
|  |                     and request[0] not in request[1:-1]): | ||||||
|  |                 request = request[1:-1] | ||||||
|             if request.lower() in ('q', 'quit'): break |             if request.lower() in ('q', 'quit'): break | ||||||
|             if request == 'help': |             if request == 'help': | ||||||
|                 self.intro() |                 self.intro() | ||||||
|  |  | ||||||
|  | @ -0,0 +1,2 @@ | ||||||
|  | Fix trailing quotation marks getting deleted when looking up byte/string | ||||||
|  | literals on pydoc. Patch by Andrés Delfino. | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andrés Delfino
						Andrés Delfino