Skip to content

Commit a98458a

Browse files
authored
fix: keep the copyreg module [backport #5750 to 1.12] (#5755)
Backport of #5750 to 1.12 Some frameworks might extend the pickle capabilities by interacting with the copyreg module. Unloading it as part of the module clean-up process causes issues, so we add it to the list of modules to keep. Fixes: #5742 ## Testing strategy The issue does not occur when the library is installed in edit mode, which makes it tricky to test with `riot` in our CI. Manual testing shows that issue that prompted this fix is resolved. ## Risk Because we don't have a reproducer in our test suite we are left vulnerable to regressions. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines) are followed. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] PR description includes explicit acknowledgement/acceptance of the performance implications of this PR as reported in the benchmarks PR comment. ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment.
1 parent 5d3a3cc commit a98458a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

ddtrace/bootstrap/sitecustomize.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,20 @@ def drop(module_name):
119119
# uses a copy of that module that is distinct from the copy that user code
120120
# gets when it does `import threading`. The same applies to every module
121121
# not in `KEEP_MODULES`.
122-
KEEP_MODULES = frozenset(["atexit", "ddtrace", "asyncio", "concurrent", "typing", "logging", "attr"])
122+
KEEP_MODULES = frozenset(
123+
[
124+
"atexit",
125+
"copyreg", # pickling issues for tracebacks with gevent
126+
"ddtrace",
127+
"asyncio",
128+
"concurrent",
129+
"typing",
130+
"logging",
131+
"attr",
132+
]
133+
)
123134
if PY2:
124-
KEEP_MODULES_PY2 = frozenset(["encodings", "codecs"])
135+
KEEP_MODULES_PY2 = frozenset(["encodings", "codecs", "copy_reg"])
125136
for m in list(_ for _ in sys.modules if _ not in LOADED_MODULES):
126137
if any(m == _ or m.startswith(_ + ".") for _ in KEEP_MODULES):
127138
continue
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
gevent: Fix a bug that caused traceback objects to fail to pickle when using gevent.

0 commit comments

Comments
 (0)