Skip to content

Commit 08acb17

Browse files
authored
fix: deprecated urllib calls (#655)
1 parent 0047fa9 commit 08acb17

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 1.43.0 [unreleased]
22

3+
### Bug Fixes
4+
1. [#655](https://github.com/influxdata/influxdb-client-python/pull/655): Replace deprecated `urllib` calls `HTTPResponse.getheaders()` and `HTTPResponse.getheader()`.
5+
36
## 1.42.0 [2024-04-17]
47

58
### Bug Fixes

influxdb_client/client/exceptions.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ def __init__(self, response: HTTPResponse = None, message: str = None):
1515
if response is not None:
1616
self.response = response
1717
self.message = self._get_message(response)
18-
self.retry_after = response.getheader('Retry-After')
18+
if isinstance(response, HTTPResponse): # response is HTTPResponse
19+
self.retry_after = response.headers.get('Retry-After')
20+
else: # response is RESTResponse
21+
self.retry_after = response.getheader('Retry-After')
1922
else:
2023
self.response = None
2124
self.message = message or 'no response'

influxdb_client/rest.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import logging
1515
from typing import Dict
16-
16+
from urllib3 import HTTPResponse
1717
from influxdb_client.client.exceptions import InfluxDBError
1818
from influxdb_client.configuration import Configuration
1919

@@ -34,7 +34,10 @@ def __init__(self, status=None, reason=None, http_resp=None):
3434
self.status = http_resp.status
3535
self.reason = http_resp.reason
3636
self.body = http_resp.data
37-
self.headers = http_resp.getheaders()
37+
if isinstance(http_resp, HTTPResponse): # response is HTTPResponse
38+
self.headers = http_resp.headers
39+
else: # response is RESTResponse
40+
self.headers = http_resp.getheaders()
3841
else:
3942
self.status = status
4043
self.reason = reason

0 commit comments

Comments
 (0)