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

Commit 62b127a

Browse files
committed
Merge branch 'master' into api_v2
2 parents 6e04415 + fbc7aa5 commit 62b127a

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v3
1818
with:
1919
fetch-depth: 0
2020

@@ -45,7 +45,7 @@ jobs:
4545
password: ${{ secrets.pypi_password }}
4646

4747
- name: Publish package to TestPyPI
48-
uses: pypa/gh-action-pypi-publish@master
48+
uses: pypa/gh-action-pypi-publish@release/v1
4949
with:
5050
user: __token__
5151
password: ${{ secrets.test_pypi_password }}

twitter/api.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,17 @@ def __call__(self, params={}, **kwargs):
377377
return self._handle_response(req, uri, arg_data, _timeout)
378378

379379
def _handle_response(self, req, uri, arg_data, _timeout=None):
380-
kwargs = {'cafile': certifi.where()}
380+
kwargs = {}
381381
if _timeout:
382382
kwargs['timeout'] = _timeout
383383
try:
384384
context = None
385-
if not self.verify_context and _HAVE_SSL:
386-
context = ssl._create_unverified_context()
385+
if _HAVE_SSL:
386+
if not self.verify_context:
387+
context = ssl._create_unverified_context()
388+
else:
389+
context = ssl.create_default_context()
390+
context.load_verify_locations(cafile=certifi.where())
387391
kwargs['context'] = context
388392
handle = urllib_request.urlopen(req, **kwargs)
389393
if handle.headers['Content-Type'] in ['image/jpeg', 'image/png']:

twitter/stream.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,13 @@ def __iter__(self):
219219
def handle_stream_response(req, uri, arg_data, block, timeout, heartbeat_timeout, verify_context=True):
220220
try:
221221
context = None
222-
if not verify_context and _HAVE_SSL:
223-
context = ssl._create_unverified_context()
224-
handle = urllib_request.urlopen(req, context=context, cafile=certifi.where())
222+
if _HAVE_SSL:
223+
if not verify_context:
224+
context = ssl._create_unverified_context()
225+
else:
226+
context = ssl.create_default_context()
227+
context.load_verify_locations(cafile=certifi.where())
228+
handle = urllib_request.urlopen(req, context=context)
225229
except urllib_error.HTTPError as e:
226230
raise TwitterHTTPError(e, uri, 'json', arg_data)
227231
return iter(TwitterJSONIter(handle, uri, arg_data, block, timeout, heartbeat_timeout))

0 commit comments

Comments
 (0)