mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	Test urlparse cache with try/except instead of has_key.
This makes it thread-safe again.
This commit is contained in:
		
							parent
							
								
									7ffbd2f86c
								
							
						
					
					
						commit
						185147f1d0
					
				
					 1 changed files with 3 additions and 1 deletions
				
			
		|  | @ -44,8 +44,10 @@ def clear_cache(): | |||
| # (e.g. netloc is a single string) and we don't expand % escapes. | ||||
| def urlparse(url, scheme = '', allow_framents = 1): | ||||
| 	key = url, scheme, allow_framents | ||||
| 	if _parse_cache.has_key(key): | ||||
| 	try: | ||||
| 	    return _parse_cache[key] | ||||
| 	except KeyError: | ||||
| 	    pass | ||||
| 	if len(_parse_cache) >= MAX_CACHE_SIZE:	# avoid runaway growth | ||||
| 	    clear_cache() | ||||
| 	netloc = path = params = query = fragment = '' | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum