Repository: yt-dlp/yt-dlp
File: yt_dlp/update.py (Python)

Code before:
                return report_unable('remove corrupt download')

        try:
            os.rename(exe, exe + '.old')
        except (IOError, OSError):
            return report_unable('move current version')
        try:
            os.rename(exe + '.new', exe)
        except (IOError, OSError):
            report_unable('overwrite current version')
            os.rename(exe + '.old', exe)
            return
        try:
            # Continues to run in the background
            subprocess.Popen(
                'ping 127.0.0.1 -n 5 -w 1000 & del /F "%s.old"' % exe,
                shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
            ydl.to_screen('Updated yt-dlp to version %s' % version_id)
            return True  # Exit app
        except OSError:
            report_unable('delete the old version')

    # Zip unix or Mac OS binary package
    elif isinstance(globals().get('__loader__'), zipimporter) or \
                   (hasattr(sys, 'frozen') and platform.system() == 'Darwin'):
        pack_type = ['mac', '64'] if hasattr(sys, 'frozen') else ['zip', '3']
        try:
            url = get_bin_info(*pack_type).get('browser_download_url')
            if not url:
                return report_network_error('fetch updates')
            urlh = ydl._opener.open(url)
            newcontent = urlh.read()
            urlh.close()
        except (IOError, OSError):
            return report_network_error('download the latest version')

        expected_sum = get_sha256sum(*pack_type)
        if not expected_sum:
            ydl.report_warning('no hash information found for the release')
        elif hashlib.sha256(newcontent).hexdigest() != expected_sum:
            return report_network_error('verify the new package')

        try:
            with open(filename, 'wb') as outf:
                outf.write(newcontent)
        except (IOError, OSError):
            return report_unable('overwrite current version')

    ydl.to_screen('Updated yt-dlp to version %s; Restart yt-dlp to use the new version' % version_id)



Review comment (suggestion):
```suggestion
    elif variant in ('zip', 'mac_bin'):
        pack_type = ('mac', '64') if variant == 'mac_bin' else ('zip', '3')
```

Code after:
                return report_unable('remove corrupt download')

        try:
            os.rename(exe, exe + '.old')
        except (IOError, OSError):
            return report_unable('move current version')
        try:
            os.rename(exe + '.new', exe)
        except (IOError, OSError):
            report_unable('overwrite current version')
            os.rename(exe + '.old', exe)
            return
        try:
            # Continues to run in the background
            subprocess.Popen(
                'ping 127.0.0.1 -n 5 -w 1000 & del /F "%s.old"' % exe,
                shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
            ydl.to_screen('Updated yt-dlp to version %s' % version_id)
            return True  # Exit app
        except OSError:
            report_unable('delete the old version')

    elif variant in ('zip', 'mac_exe'):
        pack_type = ('mac', '64') if variant == 'mac_exe' else ('zip', '3')
        try:
            url = get_bin_info(*pack_type).get('browser_download_url')
            if not url:
                return report_network_error('fetch updates')
            urlh = ydl._opener.open(url)
            newcontent = urlh.read()
            urlh.close()
        except (IOError, OSError):
            return report_network_error('download the latest version')

        expected_sum = get_sha256sum(*pack_type)
        if not expected_sum:
            ydl.report_warning('no hash information found for the release')
        elif hashlib.sha256(newcontent).hexdigest() != expected_sum:
            return report_network_error('verify the new package')

        try:
            with open(filename, 'wb') as outf:
                outf.write(newcontent)
        except (IOError, OSError):
            return report_unable('overwrite current version')

        ydl.to_screen('Updated yt-dlp to version %s; Restart yt-dlp to use the new version' % version_id)
        return

    assert False, f'Unhandled variant: {variant}'