mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Refs #23919 -- Replaced tempfile.mkdtemp() with TemporaryDirectory() context manager.
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							fee42fd99e
						
					
				
				
					commit
					6478e07a62
				
			| @@ -56,18 +56,13 @@ def symlinks_supported(): | ||||
|     host platform and/or if they are allowed to be created (e.g. | ||||
|     on Windows it requires admin permissions). | ||||
|     """ | ||||
|     tmpdir = tempfile.mkdtemp() | ||||
|     original_path = os.path.join(tmpdir, 'original') | ||||
|     symlink_path = os.path.join(tmpdir, 'symlink') | ||||
|     os.makedirs(original_path) | ||||
|     try: | ||||
|         os.symlink(original_path, symlink_path) | ||||
|         supported = True | ||||
|     except (OSError, NotImplementedError, AttributeError): | ||||
|         supported = False | ||||
|     else: | ||||
|         os.remove(symlink_path) | ||||
|     finally: | ||||
|         os.rmdir(original_path) | ||||
|         os.rmdir(tmpdir) | ||||
|     with tempfile.TemporaryDirectory() as temp_dir: | ||||
|         original_path = os.path.join(temp_dir, 'original') | ||||
|         symlink_path = os.path.join(temp_dir, 'symlink') | ||||
|         os.makedirs(original_path) | ||||
|         try: | ||||
|             os.symlink(original_path, symlink_path) | ||||
|             supported = True | ||||
|         except (OSError, NotImplementedError): | ||||
|             supported = False | ||||
|         return supported | ||||
|   | ||||
		Reference in New Issue
	
	Block a user