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 80bad79 + 4d8edcf commit 6e04415
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel
python -m pip install -r requirements.txt
- name: Build package
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
run: |
python -m pip install -U pip
python -m pip install -U pytest pytest-cov mock
python -m pip install -r requirements.txt
- name: Tests
shell: bash
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
certifi
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def local_scheme(version):
zip_safe=True,
use_scm_version={"local_scheme": local_scheme},
setup_requires=["setuptools_scm"],
install_requires=["certifi"],
entry_points="""
# -*- Entry points: -*-
[console_scripts]
Expand Down
4 changes: 3 additions & 1 deletion twitter/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import urllib2 as urllib_request
import urllib2 as urllib_error

import certifi

try:
from cStringIO import StringIO
except ImportError:
Expand Down Expand Up @@ -375,7 +377,7 @@ 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 = {}
kwargs = {'cafile': certifi.where()}
if _timeout:
kwargs['timeout'] = _timeout
try:
Expand Down
7 changes: 5 additions & 2 deletions twitter/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
else:
import urllib2 as urllib_request
import urllib2 as urllib_error

import certifi

import json
from ssl import SSLError
import socket
import codecs
import sys, select, time
import select, time

from .api import TwitterCall, wrap_response, TwitterHTTPError

Expand Down Expand Up @@ -218,7 +221,7 @@ def handle_stream_response(req, uri, arg_data, block, timeout, heartbeat_timeout
context = None
if not verify_context and _HAVE_SSL:
context = ssl._create_unverified_context()
handle = urllib_request.urlopen(req, context=context)
handle = urllib_request.urlopen(req, context=context, cafile=certifi.where())
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 6e04415

Please sign in to comment.