carsonyl / pypac

Find and use proxy auto-config (PAC) files with Python and Requests.
https://pypac.readthedocs.io
Apache License 2.0
71 stars 18 forks source link

Improve file_url_to_local_path() resiliency #54

Closed BoboTiG closed 3 years ago

BoboTiG commented 3 years ago

Relying on url2pathname() would simplify the current implementation.

BoboTiG commented 3 years ago

Hm closing as it would change the old behavior a little too much.

BoboTiG commented 3 years ago

FTR the full patch was:

def file_url_to_local_path(file_url):
    parts = urlparse(file_url)
    path = url2pathname(parts.path)
    try:
        return path if isfile(path) else None
    except (OSError, IOError):
        # IOError for Python 2
        # OSError for Python 3
        return None