Skip to content
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
2 changes: 1 addition & 1 deletion sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def object_to_json(obj, remaining_depth=4, memo=None):
safe_str(k): object_to_json(
v, remaining_depth=remaining_depth - 1, memo=memo
)
for k, v in obj.items()
for k, v in list(obj.items())
}

return safe_repr(obj)
Expand Down
32 changes: 32 additions & 0 deletions tests/integrations/wsgi/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ def app(environ, start_response):
return app


@pytest.fixture
def crashing_env_modifing_app():
class TooSmartClass(object):
def __init__(self, environ):
self.environ = environ

def __repr__(self):
if "my_representation" in self.environ:
return self.environ["my_representation"]

self.environ["my_representation"] = "<This is me>"
return self.environ["my_representation"]

def app(environ, start_response):
environ["tsc"] = TooSmartClass(environ)
1 / 0

return app


def test_basic(sentry_init, crashing_app, capture_events):
sentry_init(send_default_pii=True)
app = SentryWsgiMiddleware(crashing_app)
Expand All @@ -30,3 +50,15 @@ def test_basic(sentry_init, crashing_app, capture_events):
"query_string": "",
"url": "http://localhost/",
}


def test_env_modifing_app(sentry_init, crashing_env_modifing_app, capture_events):
sentry_init(send_default_pii=True)
app = SentryWsgiMiddleware(crashing_env_modifing_app)
client = Client(app)
events = capture_events()

with pytest.raises(ZeroDivisionError):
client.get("/")

assert len(events) == 1 # only one exception is raised