Skip to content

gh-128615: Cover pickling of ParamSpecArgs and ParamSpecKwargs #128616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 8, 2025

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -5182,6 +5182,18 @@ class C(B[int]):
x = pickle.loads(z)
self.assertEqual(s, x)

# Test ParamSpec args and kwargs
global PP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be combined into the global statement at the top of the function? (global C, PP)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feel more readable to have this name defined as global near the place where this is needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I don't feel strongly :)

pickle.loads(pickle.dumps(thing, proto)),
thing,
)
del PP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be some sort of context manager so that PP is del'd from the global namespace even if an exception in the for loop leads to the test terminating early?

should we also del the C name, which is declared as global on the first line of this function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are multiple places where this pattern is used. I think that it should be fine, because the only problem that I can think of is that PP will be reported as changed by refleak. So, not a big deal in case of a failure.

But, this can be refactored in the future, if desired.

@sobolevn sobolevn merged commit 74a5171 into python:main Jan 8, 2025
50 checks passed
@miss-islington-app
Copy link

Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 8, 2025
@bedevere-app
Copy link

bedevere-app bot commented Jan 8, 2025

GH-128625 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jan 8, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 8, 2025
@bedevere-app
Copy link

bedevere-app bot commented Jan 8, 2025

GH-128626 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Jan 8, 2025
AlexWaygood pushed a commit that referenced this pull request Jan 8, 2025
sobolevn added a commit that referenced this pull request Jan 8, 2025
…rgs` (GH-128616) (#128625)

gh-128615: Cover pickling of `ParamSpecArgs` and `ParamSpecKwargs` (GH-128616)
(cherry picked from commit 74a5171)

Co-authored-by: sobolevn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants