You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
context= dict is stored by reference and leaks between containers #568
This was generated by AI during a pre-4.0 audit of main at 9cd88e7.
Observation
container.py:89: ContextRegistry(context=context or {}) keeps the caller's dict. Reproduced:
ctx= {Req: r}
c1=root.build_child_container(context=ctx)
c2=root.build_child_container(context=ctx)
c1.set_context(User, "alice")
# c2 sees User; ctx now contains User
A module-level dict reused per request leaks set_context values across requests.
Proposal
Copy the dict on construction (dict(context)). Costs one small dict copy per child build; measure G6/G7. Observable change for code relying on the mutation, so before 4.0.
Acceptance
Failing test first; set_context on one container is invisible to siblings and to the caller's dict.
Activity
fix: copy context with copy.copy to keep dict subclasses (#568)
fix!: copy the context= dict so set_context does not leak between con…
fix: copy context with copy.copy to keep dict subclasses (#568)
fix!: copy the context= dict so set_context does not leak between con…