mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	[utils] Popen: Refactor to use contextmanager
				
					
				
			Fixes https://github.com/yt-dlp/yt-dlp/issues/3531#issuecomment-1156223597
This commit is contained in:
		| @@ -3705,14 +3705,12 @@ class YoutubeDL: | ||||
| 
 | ||||
|         if source == 'source': | ||||
|             try: | ||||
|                 sp = Popen( | ||||
|                 stdout, _, _ = Popen.run( | ||||
|                     ['git', 'rev-parse', '--short', 'HEAD'], | ||||
|                     stdout=subprocess.PIPE, stderr=subprocess.PIPE, | ||||
|                     cwd=os.path.dirname(os.path.abspath(__file__))) | ||||
|                 out, err = sp.communicate_or_kill() | ||||
|                 out = out.decode().strip() | ||||
|                 if re.match('[0-9a-f]+', out): | ||||
|                     write_debug('Git HEAD: %s' % out) | ||||
|                     text=True, cwd=os.path.dirname(os.path.abspath(__file__)), | ||||
|                     stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||||
|                 if re.fullmatch('[0-9a-f]+', stdout.strip()): | ||||
|                     write_debug(f'Git HEAD: {stdout.strip()}') | ||||
|             except Exception: | ||||
|                 with contextlib.suppress(Exception): | ||||
|                     sys.exc_clear() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 pukkandan
					pukkandan