Skip to content

Commit 2538dae

Browse files
committed
fix: fix crashing transport in py2
1 parent f558629 commit 2538dae

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

sentry_sdk/transport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def send_event(pool, event, auth):
4444
body = zlib.compress(json.dumps(event).encode("utf-8"))
4545
response = pool.request(
4646
"POST",
47-
auth.store_api_url,
47+
str(auth.store_api_url),
4848
body=body,
4949
headers={
50-
"X-Sentry-Auth": auth.to_header(),
50+
"X-Sentry-Auth": str(auth.to_header()),
5151
"Content-Type": "application/json",
5252
"Content-Encoding": "deflate",
5353
},

tests/test_client.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
import subprocess
55
from textwrap import dedent
6-
from sentry_sdk import init, Hub, Client, configure_scope
6+
from sentry_sdk import init, Hub, Client, configure_scope, capture_message
77
from sentry_sdk.hub import HubMeta
88
from sentry_sdk.transport import Transport
99
from sentry_sdk.utils import Event, Dsn
@@ -129,3 +129,14 @@ def callback(scope):
129129

130130
assert configure_scope(callback) is None
131131
assert not calls
132+
133+
134+
def test_transport_works(httpserver, request, capsys):
135+
httpserver.serve_content("ok", 200)
136+
with init("http://foobar@{}/123".format(httpserver.url[len("http://"):])):
137+
capture_message("lol")
138+
139+
request.addfinalizer(lambda: Hub.current.bind_client(None))
140+
141+
out, err = capsys.readouterr()
142+
assert not err and not out

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ envlist =
2626
[testenv]
2727
deps =
2828
pytest
29+
pytest-localserver
2930
pytest-xdist
3031
hypothesis
3132
django-{1.6,1.7,1.8}: pytest-django<3.0

0 commit comments

Comments
 (0)