Skip to content

Revert "Implement PEP3134 to discover underlying problems with python 3 (#355)" #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions aws_xray_sdk/core/async_recorder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import time
import six

from aws_xray_sdk.core.recorder import AWSXRayRecorder
from aws_xray_sdk.core.utils import stacktrace
Expand Down Expand Up @@ -82,10 +81,10 @@ async def record_subsegment_async(self, wrapped, instance, args, kwargs, name,
try:
return_value = await wrapped(*args, **kwargs)
return return_value
except Exception as exc:
exception = exc
except Exception as e:
exception = e
stack = stacktrace.get_stacktrace(limit=self._max_trace_back)
six.raise_from(exc, exc)
raise
finally:
# No-op if subsegment is `None` due to `LOG_ERROR`.
if subsegment is not None:
Expand Down
5 changes: 2 additions & 3 deletions aws_xray_sdk/core/patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import re
import sys
import wrapt
import six

from aws_xray_sdk import global_sdk_config
from .utils.compat import PY2, is_classmethod, is_instance_method
Expand Down Expand Up @@ -110,9 +109,9 @@ def patch(modules_to_patch, raise_errors=True, ignore_module_patterns=None):
def _patch_module(module_to_patch, raise_errors=True):
try:
_patch(module_to_patch)
except Exception as exc:
except Exception:
if raise_errors:
six.raise_from(exc, exc)
raise
log.debug('failed to patch module %s', module_to_patch)


Expand Down
7 changes: 3 additions & 4 deletions aws_xray_sdk/core/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os
import platform
import time
import six

from aws_xray_sdk import global_sdk_config
from aws_xray_sdk.version import VERSION
Expand Down Expand Up @@ -456,10 +455,10 @@ def record_subsegment(self, wrapped, instance, args, kwargs, name,
try:
return_value = wrapped(*args, **kwargs)
return return_value
except Exception as exc:
exception = exc
except Exception as e:
exception = e
stack = stacktrace.get_stacktrace(limit=self.max_trace_back)
six.raise_from(exc, exc)
raise
finally:
# No-op if subsegment is `None` due to `LOG_ERROR`.
if subsegment is not None:
Expand Down
10 changes: 4 additions & 6 deletions aws_xray_sdk/ext/aiohttp/middleware.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import six

"""
AioHttp Middleware
"""
Expand Down Expand Up @@ -66,14 +64,14 @@ async def middleware(request, handler):
except HTTPException as exc:
# Non 2XX responses are raised as HTTPExceptions
response = exc
six.raise_from(exc, exc)
except BaseException as exc:
raise
except BaseException as err:
# Store exception information including the stacktrace to the segment
response = None
segment.put_http_meta(http.STATUS, 500)
stack = stacktrace.get_stacktrace(limit=xray_recorder.max_trace_back)
segment.add_exception(exc, stack)
six.raise_from(exc, exc)
segment.add_exception(err, stack)
raise
finally:
if response is not None:
segment.put_http_meta(http.STATUS, response.status)
Expand Down
7 changes: 3 additions & 4 deletions aws_xray_sdk/ext/sqlalchemy_core/patch.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import logging
import sys
import wrapt
import six

if sys.version_info >= (3, 0, 0):
from urllib.parse import urlparse, uses_netloc
else:
from urlparse import urlparse, uses_netloc

import wrapt

from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core.patcher import _PATCHED_MODULES
Expand Down Expand Up @@ -73,12 +72,12 @@ def _process_request(wrapped, engine_instance, args, kwargs):
subsegment = None
try:
res = wrapped(*args, **kwargs)
except Exception as exc:
except Exception:
if subsegment is not None:
exception = sys.exc_info()[1]
stack = stacktrace.get_stacktrace(limit=xray_recorder._max_trace_back)
subsegment.add_exception(exception, stack)
six.raise_from(exc, exc)
raise
finally:
if subsegment is not None:
subsegment.set_sql(sql)
Expand Down