Skip to content

Commit

Permalink
fix: deprecated urllib calls (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
alespour authored May 14, 2024
1 parent 0047fa9 commit 08acb17
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 1.43.0 [unreleased]

### Bug Fixes
1. [#655](https://github.com/influxdata/influxdb-client-python/pull/655): Replace deprecated `urllib` calls `HTTPResponse.getheaders()` and `HTTPResponse.getheader()`.

## 1.42.0 [2024-04-17]

### Bug Fixes
Expand Down
5 changes: 4 additions & 1 deletion influxdb_client/client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ def __init__(self, response: HTTPResponse = None, message: str = None):
if response is not None:
self.response = response
self.message = self._get_message(response)
self.retry_after = response.getheader('Retry-After')
if isinstance(response, HTTPResponse): # response is HTTPResponse
self.retry_after = response.headers.get('Retry-After')
else: # response is RESTResponse
self.retry_after = response.getheader('Retry-After')
else:
self.response = None
self.message = message or 'no response'
Expand Down
7 changes: 5 additions & 2 deletions influxdb_client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import logging
from typing import Dict

from urllib3 import HTTPResponse
from influxdb_client.client.exceptions import InfluxDBError
from influxdb_client.configuration import Configuration

Expand All @@ -34,7 +34,10 @@ def __init__(self, status=None, reason=None, http_resp=None):
self.status = http_resp.status
self.reason = http_resp.reason
self.body = http_resp.data
self.headers = http_resp.getheaders()
if isinstance(http_resp, HTTPResponse): # response is HTTPResponse
self.headers = http_resp.headers
else: # response is RESTResponse
self.headers = http_resp.getheaders()
else:
self.status = status
self.reason = reason
Expand Down

0 comments on commit 08acb17

Please sign in to comment.