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

gh-94598: Remove deprecated ssl modules features #94599

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tiran
Copy link
Member

@tiran tiran commented Jul 6, 2022

@tiran
Copy link
Member Author

tiran commented Jul 6, 2022

  • documentation updates are still work in progress
  • update whatsnew in 3.12 and porting to 3.12

@tiran tiran force-pushed the py312_ssl_removal branch 3 times, most recently from ae51bdc to cfe4777 Compare July 8, 2022 13:30
@tiran tiran force-pushed the py312_ssl_removal branch from cfe4777 to 72c5941 Compare July 20, 2022 08:01
@graingert
Copy link
Contributor

graingert commented Jul 20, 2022

Can you make these attributes warn on access in 3.11? using the approach here

def __getattr__(name):
"""
For backwards compatibility, continue to make names
from _resources_abc available through this module. #93963
"""
if name in _resources_abc.__all__:
obj = getattr(_resources_abc, name)
warnings._deprecated(f"{__name__}.{name}", remove=(3, 14))
globals()[name] = obj
return obj
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')

Currently they only warn at use, and it would make testing this change much easier if they warn on access

@tiran
Copy link
Member Author

tiran commented Jul 21, 2022

Enum's convert helper gets in the way. It adds the variables to global name space unconditionally.

@graingert
Copy link
Contributor

Could you del the globals, adding them back with __getattr__?

@tiran
Copy link
Member Author

tiran commented Jul 21, 2022

That's ugly.

@hugovk
Copy link
Member

hugovk commented Jul 27, 2022

It's ugly but it would give users a heads-up this is going to be removed.

@tiran
Copy link
Member Author

tiran commented Jul 27, 2022

It's ugly but it would give users a heads-up this is going to be removed.

The ssl module has been warning about deprecated features since 3.10:

$ python3.10 -Werror -c 'import ssl; ssl.SSLContext(ssl.PROTOCOL_TLS)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.10/ssl.py", line 496, in __new__
    self = _SSLContext.__new__(cls, protocol)
DeprecationWarning: ssl.PROTOCOL_TLS is deprecated

Functions and methods don't warn on attribute access either. They typically warn when they are called (used).

@tiran tiran force-pushed the py312_ssl_removal branch from 72c5941 to 9f709b0 Compare July 27, 2022 09:36
@tiran
Copy link
Member Author

tiran commented Jul 27, 2022

Compromise: 3.11 is at the end of its beta phase. I don't want to add ugly code to it. Instead I'm going to add warnings for the deprecated module constants to 3.12 and remove them in 3.13. They won't work in 3.12, though. Attribute access won't raise an AttributeError.

$ ./python -Wonce -c "import ssl; print(ssl.PROTOCOL_TLS)"
<string>:1: DeprecationWarning: ssl.PROTOCOL_TLS is no longer supported. The constants will be removed in 3.13. Use ssl.PROTOCOL_TLS_CLIENT or ssl.PROTOCOL_TLS_SERVER instead.
NotImplemented
$ ./python -Wonce -c "import ssl; print(ssl.OP_NO_TLSv1)"
<string>:1: DeprecationWarning: ssl.OP_NO_TLSv1 is no longer supported. The constants will be removed in 3.13. Use SSLContext's 'minimum_version' and 'maximum_version' properties instead.
67108864

@@ -427,17 +477,6 @@ class SSLContext(_SSLContext):
sslsocket_class = None # SSLSocket is assigned later.
sslobject_class = None # SSLObject is assigned later.

def __new__(cls, protocol=None, *args, **kwargs):

This comment was marked as outdated.

@arhadthedev
Copy link
Member

Deprecated :mod:`ssl` features have been removed

  • support for SSL 3.0, TLS 1.0, and TLS 1.1
  • all ``PROTOCOL_*`` constants except ``PROTOCOL_TLS_CLIENT`` and ``PROTOCOL_TLS_SERVER``
  • all ``OP_NO_SSL*`` and ``OP_NO_TLS*`` option flags
  • ``TLSVersion.SSLv3``, ``TLSVersion.TLSv1``, and ``TLSVersion.TLSv1_1``
  • :class:`ssl.SSLContext` now requires a protocol argument

Is there any chance to get it into 3.12b1?

cc @dstufft, @alex

@arhadthedev arhadthedev added stdlib Python modules in the Lib dir topic-SSL labels May 5, 2023
@erlend-aasland
Copy link
Contributor

Is there any chance to get it into 3.12b1?

Feel free to pick it up and prepare it for the next 3.13 alpha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review stdlib Python modules in the Lib dir topic-SSL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants