Сообщение об ошибке вот.
Сам код большой дюже и для работы ему нужны ключи на API, которые я здесь выложить не могу, а без них он работать не будет.
Вываливается именно на data = json.loads(self.current_url.read().decode())
Собственно я для эксперимента просто даю ему неправильный URL в current_url
Меня в общем-то в логике не интересует, по какой причине оно там вываливается, интернета ли нет или ещё что.
Поднялось исключение, значит не получилось. Это всё, что нужно.
Почему оно не обрабатывает это исключение, не пойму.
Собственно, их два, как я понял из сообщения.
Происходят они здесь
socket.gaierror: getaddrinfo failed
def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
addrlist = []
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
af, socktype, proto, canonname, sa = res
addrlist.append((_intenum_converter(af, AddressFamily),
_intenum_converter(socktype, SocketKind),
proto, canonname, sa))
return addrlist
urllib.error.URLError: <urlopen error getaddrinfo failed>
try:
try:
h.request(req.get_method(), req.selector, req.data, headers,
encode_chunked=req.has_header('Transfer-encoding'))
except OSError as err: # timeout error
raise URLError(err)
r = h.getresponse()
except:
h.close()
raise
Спасибо
Traceback (most recent call last):
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1317, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1230, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1276, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1225, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1004, in _send_output
self.send(msg)
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 944, in send
self.connect()
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 915, in connect
self.sock = self._create_connection(
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\socket.py", line 787, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\socket.py", line 914, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/msmolkin/YandexDisk/ws/ws3.py", line 308, in <module>
window()
File "C:/Users/msmolkin/YandexDisk/ws/ws3.py", line 295, in window
win = MainWindow()
File "C:/Users/msmolkin/YandexDisk/ws/ws3.py", line 26, in __init__
self.initWindow()
File "C:/Users/msmolkin/YandexDisk/ws/ws3.py", line 201, in initWindow
self.get_weather()
File "C:/Users/msmolkin/YandexDisk/ws/ws3.py", line 287, in get_weather
with urllib.request.urlopen(self.current_url) as self.current_url:
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1346, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\msmolkin\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11004] getaddrinfo failed>
Process finished with exit code 1