getsentry / raven-python

Raven is the legacy Python client for Sentry (getsentry.com) — replaced by sentry-python
https://sentry.io
BSD 3-Clause "New" or "Revised" License
1.68k stars 657 forks source link

Ensure that all keys in locals are strings before serializing #1273

Closed brakhane closed 5 years ago

brakhane commented 5 years ago

Trio uses an ugly hack and puts a value into locals with a non string key (class LOCALS_KI_PROTECTION_ENABLED).

When trying to serialize that, JsonEncoder crashes. So we ensure that every key is indeed a string.

Another way to solve this problem would be to pass skipkeys=True to json.dumps, but this might mask other errors.

brakhane commented 5 years ago

This took really long to find, because of #1155 masking the real error, BTW. It would be nice if an exception during serialization wouldn't fail with a confusing message on Python3.

Here's the line in trio that adds a guard object into locals: https://github.com/python-trio/trio/blob/79d66647c3c947f614b51f607be6fd527df6777f/trio/_core/_run.py#L1245