Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit ba876d5

Browse files
bbolliboogheta
authored andcommitted
Simplify usage of verify_context
bf33714 ("url lib support no auth for https", 2019-05-13) added a new instance variable verify_context, but still passed it around to internal methods as if it were not known in the instance. Simplify the code to always use self.verify_context.
1 parent 2e954b2 commit ba876d5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

twitter/api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,17 @@ def __call__(self, **kwargs):
359359
req.get_method = lambda: method
360360

361361
if self.retry:
362-
return self._handle_response_with_retry(req, uri, arg_data, _timeout, self.verify_context)
362+
return self._handle_response_with_retry(req, uri, arg_data, _timeout)
363363
else:
364-
return self._handle_response(req, uri, arg_data, _timeout, self.verify_context)
364+
return self._handle_response(req, uri, arg_data, _timeout)
365365

366-
def _handle_response(self, req, uri, arg_data, _timeout=None, verify_context=True):
366+
def _handle_response(self, req, uri, arg_data, _timeout=None):
367367
kwargs = {}
368368
if _timeout:
369369
kwargs['timeout'] = _timeout
370370
try:
371371
context = None
372-
if not verify_context and _HAVE_SSL:
372+
if not self.verify_context and _HAVE_SSL:
373373
context = ssl._create_unverified_context()
374374
kwargs['context'] = context
375375
handle = urllib_request.urlopen(req, **kwargs)
@@ -400,11 +400,11 @@ def _handle_response(self, req, uri, arg_data, _timeout=None, verify_context=Tru
400400
else:
401401
raise TwitterHTTPError(e, uri, self.format, arg_data)
402402

403-
def _handle_response_with_retry(self, req, uri, arg_data, _timeout=None, verify_context=True):
403+
def _handle_response_with_retry(self, req, uri, arg_data, _timeout=None):
404404
retry = self.retry
405405
while retry:
406406
try:
407-
return self._handle_response(req, uri, arg_data, _timeout, verify_context)
407+
return self._handle_response(req, uri, arg_data, _timeout)
408408
except TwitterHTTPError as e:
409409
if e.e.code == 429:
410410
# API rate limit reached

0 commit comments

Comments
 (0)