Skip to content

Commit

Permalink
Merge branch 'master' into api_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
boogheta committed Sep 14, 2022
2 parents 6e04415 + fbc7aa5 commit 62b127a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
password: ${{ secrets.pypi_password }}

- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
Expand Down
10 changes: 7 additions & 3 deletions twitter/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,17 @@ def __call__(self, params={}, **kwargs):
return self._handle_response(req, uri, arg_data, _timeout)

def _handle_response(self, req, uri, arg_data, _timeout=None):
kwargs = {'cafile': certifi.where()}
kwargs = {}
if _timeout:
kwargs['timeout'] = _timeout
try:
context = None
if not self.verify_context and _HAVE_SSL:
context = ssl._create_unverified_context()
if _HAVE_SSL:
if not self.verify_context:
context = ssl._create_unverified_context()
else:
context = ssl.create_default_context()
context.load_verify_locations(cafile=certifi.where())
kwargs['context'] = context
handle = urllib_request.urlopen(req, **kwargs)
if handle.headers['Content-Type'] in ['image/jpeg', 'image/png']:
Expand Down
10 changes: 7 additions & 3 deletions twitter/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,13 @@ def __iter__(self):
def handle_stream_response(req, uri, arg_data, block, timeout, heartbeat_timeout, verify_context=True):
try:
context = None
if not verify_context and _HAVE_SSL:
context = ssl._create_unverified_context()
handle = urllib_request.urlopen(req, context=context, cafile=certifi.where())
if _HAVE_SSL:
if not verify_context:
context = ssl._create_unverified_context()
else:
context = ssl.create_default_context()
context.load_verify_locations(cafile=certifi.where())
handle = urllib_request.urlopen(req, context=context)
except urllib_error.HTTPError as e:
raise TwitterHTTPError(e, uri, 'json', arg_data)
return iter(TwitterJSONIter(handle, uri, arg_data, block, timeout, heartbeat_timeout))
Expand Down

0 comments on commit 62b127a

Please sign in to comment.