X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/fc03c0266a908e3aaec11530aa7f1d0af967aa2e..4da1f0da6fc42f00b2a9aeeacd2bb1d41e664510:/nominatim/tools/exec_utils.py?ds=inline diff --git a/nominatim/tools/exec_utils.py b/nominatim/tools/exec_utils.py index 6b080792..4e6afdc2 100644 --- a/nominatim/tools/exec_utils.py +++ b/nominatim/tools/exec_utils.py @@ -7,7 +7,7 @@ """ Helper functions for executing external programs. """ -from typing import Any, Union, Optional, Mapping +from typing import Any, Union, Optional, Mapping, IO from pathlib import Path import logging import subprocess @@ -160,7 +160,8 @@ def get_url(url: str) -> str: headers = {"User-Agent": f"Nominatim/{version_str()}"} try: - with urlrequest.urlopen(urlrequest.Request(url, headers=headers)) as response: + request = urlrequest.Request(url, headers=headers) + with urlrequest.urlopen(request) as response: # type: IO[bytes] return response.read().decode('utf-8') except Exception: LOG.fatal('Failed to load URL: %s', url)