Uh oh!
There was an error while loading. Please reload this page.
gh-118921: Add copy() method for FrameLocalsProxy - #118923
Merged
Merged
Conversation
gaogaotiantian
commented
May 10, 2024
MemberAuthor
@gvanrossum do we want to support |
gvanrossum
left a comment
Member
There was a problem hiding this comment.
LG, one nit. I don't think there's much evidence that people are using copy.copy() for the same purpose, and mappingproxy doesn't support it either.
| x = 0 | ||
| d = sys._getframe().f_locals | ||
| d_copy = d.copy() | ||
| self.assertIs(type(d_copy), dict) |
Member
There was a problem hiding this comment.
I think assertIsInstance is good enough here.
MemberAuthor
There was a problem hiding this comment.
Right, I did not use that method a lot so I didn't think of it.
gvanrossum
approved these changes
May 10, 2024
Thanks @gaogaotiantian for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
miss-islington pushed a commit
to miss-islington/cpython
that referenced
this pull request
May 10, 2024
GH-118933 is a backport of this pull request to the 3.13 branch. |
gvanrossum pushed a commit
that referenced
this pull request
May 10, 2024
szef1233
approved these changes
May 11, 2024
rominf added a commit
to rominf/sentry-python
that referenced
this pull request
Jul 10, 2024
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#118921python/cpython#118923https://docs.python.org/3.13/whatsnew/3.13.html#porting-to-python-3-13https://docs.python.org/3/library/copy.html
rominf added a commit
to rominf/sentry-python
that referenced
this pull request
Jul 10, 2024
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). Since Python 3.13, `FrameLocalsProxy` skips items of `locals()` that have non-`str` keys; this is a CPython implementation detail, so we hence disable `test_non_string_variables` test on Python 3.13. See: https://peps.python.org/pep-0667/python/cpython#118921python/cpython#118923https://docs.python.org/3.13/whatsnew/3.13.html#porting-to-python-3-13https://docs.python.org/3/library/copy.htmlhttps://github.com/python/cpython/blame/7b413952e817ae87bfda2ac85dd84d30a6ce743b/Objects/frameobject.c#L148
sentrivana pushed a commit
to getsentry/sentry-python
that referenced
this pull request
Jul 16, 2024
…3271) 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). Since Python 3.13, `FrameLocalsProxy` skips items of `locals()` that have non-`str` keys; this is a CPython implementation detail, so we hence disable `test_non_string_variables` test on Python 3.13. See: https://peps.python.org/pep-0667/python/cpython#118921python/cpython#118923https://docs.python.org/3.13/whatsnew/3.13.html#porting-to-python-3-13https://docs.python.org/3/library/copy.htmlhttps://github.com/python/cpython/blame/7b413952e817ae87bfda2ac85dd84d30a6ce743b/Objects/frameobject.c#L148
sentrivana added a commit
to getsentry/sentry-python
that referenced
this pull request
Jul 16, 2024
Adding preliminary support for Python 3.13. The `_partialmethod` attribute of methods wrapped with `partialmethod()` was renamed to `__partialmethod__` in CPython 3.13: python/cpython#16600 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). Since Python 3.13, `FrameLocalsProxy` skips items of `locals()` that have non-`str` keys; this is a CPython implementation detail, so we hence disable `test_non_string_variables` test on Python 3.13. See: https://peps.python.org/pep-0667/python/cpython#118921python/cpython#118923https://docs.python.org/3.13/whatsnew/3.13.html#porting-to-python-3-13https://docs.python.org/3/library/copy.htmlhttps://github.com/python/cpython/blame/7b413952e817ae87bfda2ac85dd84d30a6ce743b/Objects/frameobject.c#L148 --------- Co-authored-by: Roman Inflianskas <rominf@pm.me>
estyxx pushed a commit
to estyxx/cpython
that referenced
this pull request
Jul 17, 2024
arjennienhuis pushed a commit
to arjennienhuis/sentry-python
that referenced
this pull request
Sep 30, 2024
Adding preliminary support for Python 3.13. The `_partialmethod` attribute of methods wrapped with `partialmethod()` was renamed to `__partialmethod__` in CPython 3.13: python/cpython#16600 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). Since Python 3.13, `FrameLocalsProxy` skips items of `locals()` that have non-`str` keys; this is a CPython implementation detail, so we hence disable `test_non_string_variables` test on Python 3.13. See: https://peps.python.org/pep-0667/python/cpython#118921python/cpython#118923https://docs.python.org/3.13/whatsnew/3.13.html#porting-to-python-3-13https://docs.python.org/3/library/copy.htmlhttps://github.com/python/cpython/blame/7b413952e817ae87bfda2ac85dd84d30a6ce743b/Objects/frameobject.c#L148 --------- Co-authored-by: Roman Inflianskas <rominf@pm.me>
turicas added a commit
to turicas/sentry-python
that referenced
this pull request
Jun 6, 2025
Partial cherry-pick of: a98f660 Adding preliminary support for Python 3.13. The `_partialmethod` attribute of methods wrapped with `partialmethod()` was renamed to `__partialmethod__` in CPython 3.13: python/cpython#16600 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). Since Python 3.13, `FrameLocalsProxy` skips items of `locals()` that have non-`str` keys; this is a CPython implementation detail, so we hence disable `test_non_string_variables` test on Python 3.13. See: https://peps.python.org/pep-0667/python/cpython#118921python/cpython#118923https://docs.python.org/3.13/whatsnew/3.13.html#porting-to-python-3-13https://docs.python.org/3/library/copy.htmlhttps://github.com/python/cpython/blame/7b413952e817ae87bfda2ac85dd84d30a6ce743b/Objects/frameobject.c#L148
turicas added a commit
to turicas/sentry-python
that referenced
this pull request
Jun 6, 2025
Partial cherry-pick of: a98f660 Adding preliminary support for Python 3.13. The `_partialmethod` attribute of methods wrapped with `partialmethod()` was renamed to `__partialmethod__` in CPython 3.13: python/cpython#16600 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). Since Python 3.13, `FrameLocalsProxy` skips items of `locals()` that have non-`str` keys; this is a CPython implementation detail, so we hence disable `test_non_string_variables` test on Python 3.13. See: https://peps.python.org/pep-0667/python/cpython#118921python/cpython#118923https://docs.python.org/3.13/whatsnew/3.13.html#porting-to-python-3-13https://docs.python.org/3/library/copy.htmlhttps://github.com/python/cpython/blame/7b413952e817ae87bfda2ac85dd84d30a6ce743b/Objects/frameobject.c#L148
turicas added a commit
to turicas/sentry-python
that referenced
this pull request
Jun 6, 2025
Partial cherry-pick of: a98f660 Adding preliminary support for Python 3.13. The `_partialmethod` attribute of methods wrapped with `partialmethod()` was renamed to `__partialmethod__` in CPython 3.13: python/cpython#16600 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). Since Python 3.13, `FrameLocalsProxy` skips items of `locals()` that have non-`str` keys; this is a CPython implementation detail, so we hence disable `test_non_string_variables` test on Python 3.13. See: https://peps.python.org/pep-0667/python/cpython#118921python/cpython#118923https://docs.python.org/3.13/whatsnew/3.13.html#porting-to-python-3-13https://docs.python.org/3/library/copy.htmlhttps://github.com/python/cpython/blame/7b413952e817ae87bfda2ac85dd84d30a6ce743b/Objects/frameobject.c#L148
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
frame.f_locals.copy()return a snapshot dict off_locals#118921