Skip to content
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

PEP 699: Follow standard deprecation policy #2927

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Dec 16, 2022

This PR amends the PEP to follow the standard deprecation policy, in line with the SC's feedback on the Discourse thread https://discuss.python.org/t/pep-699-remove-private-dict-version-field-added-in-pep-509/19724/10?u=kj0.

@markshannon
Copy link
Member

markshannon commented Dec 16, 2022

OOI, how do you propose to emit a compiler warning for the ma_verison_tag field without creating lots of warnings when building CPython?

@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 16, 2022

OOI, how do you propose to emit a compiler warning for the ma_verison_tag field without creating lots of warnings when building CPython?

We would have to move the dict watchers data to some other field. Then we can remove all uses of ma_version_tag in CPython, which should hopefully mean no warnings when we compile CPython.

@markshannon
Copy link
Member

markshannon commented Dec 16, 2022

Until we remove the field, we need to update it, otherwise we should just remove it.
Leaving it, but not updating it, breaks any code using it.

@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 16, 2022

I was wondering: don't dict watchers break it already? Or at least makes it backwards incompatible to a certain extent?

@markshannon
Copy link
Member

markshannon commented Dec 16, 2022

dict watchers use the low 8 bits. The only change is that the dict-version could wrap in a few years, rather than centuries.

@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 16, 2022

Hmm ok, this clearly needs more discussion. Mark do you mind responding on the discourse thread with your opinions on why we should remove it immediately?

@markshannon
Copy link
Member

markshannon commented Dec 16, 2022

My thinking is that the ma_version_tag cannot be deprecated with a compiler warning, because we need to update the value every time we update the dict.

Is it possible (in GCC or some other compiler) to deprecate the attribute, and then suppress the warnings only for the places we use it?

@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 16, 2022

Ohh right I get what you mean. Hmmm this is a pickle. I need to think about it.

@markshannon
Copy link
Member

markshannon commented Dec 16, 2022

You could try replacing uint64_t ma_version_tag with this:

union {
    uint64_t ma_version_tag  __attribute__ ((deprecated));
    uint64_t internal_vt; /* Internal. Do not use. May be removed without warning! */
};

And replacing all uses of ma_version_tag with internal_vt.

@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 18, 2022

And replacing all uses of ma_version_tag with internal_vt.

But we still need to maintain the semantics of ma_version_tag until we remove it right? That would mean internally we still need to write to it and update it, which would trigger cpython build warnings?

@kumaraditya303
Copy link

kumaraditya303 commented Dec 19, 2022

Is it possible (in GCC or some other compiler) to deprecate the attribute, and then suppress the warnings only for the places we use it?

We can deprecate the attribute for extension modules but not for core code and continue to use it as usual. The warning will only be emitted for extension modules. See my implementation of this idea kumaraditya303/cpython#15

@markshannon
Copy link
Member

markshannon commented Dec 19, 2022

But we still need to maintain the semantics of ma_version_tag until we remove it right? That would mean internally we still need to write to it and update it, which would trigger cpython build warnings?

We update it without warning through internal_vt. That's what the union is for.

@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 19, 2022

But we still need to maintain the semantics of ma_version_tag until we remove it right? That would mean internally we still need to write to it and update it, which would trigger cpython build warnings?

We update it without warning through internal_vt. That's what the union is for.

Sorry, I didn't read it properly on my phone. I see what you mean now. Thanks.

@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 19, 2022

OK, I think both solutions are viable. Thanks Mark and Kumar! I've thanked both of you in the PEP. I think this is ready now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants