Skip to content

Commit 5536c2a

Browse files
committed
fix(tests): Fix exception on copying frame.f_locals (Python 3.13)
Starting from Python 3.13, `frame.f_locals` is not `dict` anymore, but `FrameLocalsProxy`, that cannot be copied using `copy.copy()`. In Python 3.13 and later, it should be copied using a method `.copy()`. The new way of copying works the same as the old one for versions of Python prior to 3.13, according to the documentation (both copying methods produce a shallow copy). See: https://peps.python.org/pep-0667/ python/cpython#118921 python/cpython#118923 https://docs.python.org/3.13/whatsnew/3.13.html#porting-to-python-3-13 https://docs.python.org/3/library/copy.html
1 parent 4f5fe0a commit 5536c2a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

sentry_sdk/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import threading
1212
import time
1313
from collections import namedtuple
14-
from copy import copy
1514
from datetime import datetime
1615
from decimal import Decimal
1716
from functools import partial, partialmethod, wraps
@@ -618,7 +617,7 @@ def serialize_frame(
618617
)
619618

620619
if include_local_variables:
621-
rv["vars"] = copy(frame.f_locals)
620+
rv["vars"] = frame.f_locals.copy()
622621

623622
return rv
624623

0 commit comments

Comments
 (0)