-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
gh-88427: Deprecate socket.SocketType
#126272
base: main
Are you sure you want to change the base?
Conversation
socket.SocketType
socket.SocketType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SocketType
isn't deprecated right now, so we can't remove it yet.
Please update the PR to raise a DeprecationWarning
when accessing a SocketType
(you can do this via a PEP-562 __getattr__
), and then add the documentation notes.
Maybe we can wait for the promoter to answer. I won't open this PR before I decide whether to abandon or remove it. |
I looked at the code again and agree with my opinion from 2021: it should be deprecated and eventually removed. It could be useful to do a code search (e.g., GitHub code search, Hugo's top 5k pypi packages tool) to see how the name is being used. A possible approach to deprecation could be to remove the current line adding it to |
Okay, I'll re-revise this PR so that it throws a warning when calling this type. Call me back in this PR when we consider removing it in the future :) |
Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst
Outdated
Show resolved
Hide resolved
It seems that the module |
It works for any kind of attributes. Please, read PEP-562 for examples on how to use it. |
I read the document and modified it. But why does it trigger this
Edit |
I think you need to raise an |
socket.SocketType
socket.SocketType
Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst
Outdated
Show resolved
Hide resolved
if (PyModule_AddObjectRef(m, "SocketType", sock_type) < 0) { | ||
goto error; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, could users have been relying on _socket.SocketType
instead of socket.SocketType
?
I have changed them as required. Please review them again :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rruuaanng, please don't mark conversations as resolved without addressing it them first.
Sorry, the removal of _socket.SocketType
without a deprecation is problematic. Normally I wouldn't care about private APIs, but other Python implementations are exposing it for consistency, and it doesn't seem right for us to remove that without a deprecation period.
@vstinner, could you take a second look? (I'm not 100% certain what our policy for other Python implementations is, it's possibly fine to merge as is, but I'd like a second set of eyes.)
if (PyModule_AddObjectRef(m, "SocketType", sock_type) < 0) { | ||
goto error; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this part is a breaking change. Please add it back temporarily. (We possibly need to add a __getattr__
to the C code as well to emit a deprecation.)
There are a few large things downstream relying on this:
- RustPython uses it in their tests.
- IronPython has it.
- cosmopolitan exposes it as an API.
- trio is doing some weird things with
SocketType
, but it's possibly unrelated.
Nonetheless, I don't want to give users of other implementations an unpleasant surprise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, can we add a module-level __getattr__
to _socket
too that raises a DeprecationWarning?
It has no issues. Since I wrote it in the socket, if this property is used, it returns I don't think it hasn't been solved. |
I'll double check, but you wrote it for the Edit: Yup
|
Yes. But private modules have always been unstable (in my view, it's not surprising if some features are missing, since we don't encourage their use and remain vigilant about the behavior they exhibit). From jelle
|
|
I think we could add a getter in the C code, but I’m not sure how Victor feels about it. He didn’t raise any concerns about this during the audit, so maybe he had other considerations in mind. |
Victor likely didn't notice because you marked my comment as resolved :( |
Emmm, maybe he saw it but didn’t think there was any issue. We can wait for his reply. |
Alright, if possible, it would be better to implement I didn't know that _socket.SocketType is used currently. |
cc @JelleZijlstra