mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	Replace sequential split/join calls on strings with a single replace call.
Thanks Andrew Gaul.
This commit is contained in:
		
							parent
							
								
									708b4dacf4
								
							
						
					
					
						commit
						aaeffaf01e
					
				
					 2 changed files with 5 additions and 11 deletions
				
			
		|  | @ -169,9 +169,7 @@ def open(self, fullurl, data=None): | |||
|             proxy = None | ||||
|         name = 'open_' + urltype | ||||
|         self.type = urltype | ||||
|         if '-' in name: | ||||
|             # replace - with _ | ||||
|             name = '_'.join(name.split('-')) | ||||
|         name = name.replace('-', '_') | ||||
|         if not hasattr(self, name): | ||||
|             if proxy: | ||||
|                 return self.open_unknown_proxy(proxy, fullurl, data) | ||||
|  | @ -1045,9 +1043,7 @@ def unquote(s): | |||
| 
 | ||||
| def unquote_plus(s): | ||||
|     """unquote('%7e/abc+def') -> '~/abc def'""" | ||||
|     if '+' in s: | ||||
|         # replace '+' with ' ' | ||||
|         s = ' '.join(s.split('+')) | ||||
|     s = s.replace('+', ' ') | ||||
|     return unquote(s) | ||||
| 
 | ||||
| always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brett Cannon
						Brett Cannon