Skip to content

Commit 2660812

Browse files
committed
2.7 fixes
1 parent 44990bb commit 2660812

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

sentry_sdk/integrations/aiohttp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import json
22
import sys
33
import weakref
4-
from urllib.parse import parse_qsl
4+
5+
try:
6+
from urllib.parse import parse_qsl
7+
except ImportError:
8+
from urlparse import parse_qsl
59

610
from sentry_sdk.api import continue_trace
711
from sentry_sdk._compat import reraise

sentry_sdk/integrations/httpx.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import json
2-
from urllib.parse import parse_qsl
2+
3+
try:
4+
from urllib.parse import parse_qsl
5+
except ImportError:
6+
from urlparse import parse_qsl
37

48
from sentry_sdk import Hub
59
from sentry_sdk.consts import OP, SPANDATA

sentry_sdk/integrations/stdlib.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import subprocess
44
import sys
55
import platform
6-
from urllib.parse import parse_qs, urlparse
6+
7+
try:
8+
from urllib.parse import parse_qsl
9+
except ImportError:
10+
from urlparse import parse_qsl
711

812
from sentry_sdk.consts import OP, SPANDATA
913
from sentry_sdk.hub import Hub
@@ -158,7 +162,7 @@ def getresponse(self, *args, **kwargs):
158162
return rv
159163

160164
if isinstance(response_body, dict) and response_body.get("errors"):
161-
method = getattr(self, "_sentrysdk_method", None)
165+
method = getattr(self, "_sentrysdk_method", None) # type: Optional[str]
162166
request_body = getattr(self, "_sentry_request_body", None)
163167
hub = Hub.current
164168
with hub.configure_scope() as scope:
@@ -189,19 +193,18 @@ def getresponse(self, *args, **kwargs):
189193

190194

191195
def _make_request_processor(url, method, status, request_body, response_body):
192-
# type: (Optional[str], str, int, Any, Any) -> EventProcessor
196+
# type: (str, Optional[str], int, Any, Any) -> EventProcessor
193197
def stdlib_processor(
194198
event, # type: Dict[str, Any]
195199
hint, # type: Dict[str, Tuple[type, BaseException, Any]]
196200
):
201+
# type: (...) -> Optional[Event]
197202
with capture_internal_exceptions():
198203
request_info = event.setdefault("request", {})
199204

200-
if url is not None:
201-
parsed_url = urlparse(url)
202-
request_info["query_string"] = parsed_url.query
203-
request_info["url"] = url
204-
205+
parsed_url = parse_url(url, sanitize=False)
206+
request_info["query_string"] = parsed_url.query
207+
request_info["url"] = url
205208
request_info["method"] = method
206209
try:
207210
request_info["data"] = json.loads(request_body)
@@ -213,11 +216,11 @@ def stdlib_processor(
213216
response_context = contexts.setdefault("response", {})
214217
response_context["data"] = response_body
215218

216-
if parsed_url.path == "/graphql":
219+
if parsed_url.url.endswith("/graphql"):
217220
request_info["api_target"] = "graphql"
218221
query = request_info.get("data")
219222
if method == "GET":
220-
query = parse_qs(parsed_url.query)
223+
query = dict(parse_qsl(parsed_url.query))
221224

222225
if query:
223226
operation_name = _get_graphql_operation_name(query)

0 commit comments

Comments
 (0)