Skip to content

Commit d8d5614

Browse files
committed
Constrain acceptable types further.
1 parent b0b1984 commit d8d5614

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/sentry/celery.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import gc
2-
import os
32
from datetime import datetime
43
from itertools import chain
54
from typing import Any
@@ -44,19 +43,14 @@ def holds_bad_pickle_object(value, memo=None):
4443
)
4544
app_module = type(value).__module__
4645
if app_module.startswith(("sentry.", "getsentry.")):
47-
return value, "do not pickle custom classes"
46+
return value, "do not pickle application classes"
4847
elif isinstance(value, SafeString):
4948
# Django string wrappers json encode fine
5049
return None
51-
elif app_module != "builtins":
52-
return value, "do not pickle custom classes"
53-
54-
if os.getenv("TASK_TYPE_CHECKING") and os.getenv("TASK_TYPE_CHECKING") != "0":
55-
if isinstance(value, SafeString):
56-
# Django string wrappers json encode fine
57-
return None
58-
elif app_module != "builtins":
59-
return value, "do not pickle custom classes"
50+
elif value is None:
51+
return None
52+
elif not isinstance(value, (dict, list, str, float, int, bool, tuple, frozenset)):
53+
return value, "do not pickle stdlib classes"
6054
return None
6155

6256

0 commit comments

Comments
 (0)