Add deprecation warnings for pyOpenSSL and the [secure] extra
MODIFY
.coveragerc
.coveragerc
@@ -16,6 +16,7 @@ source =
[report]
exclude_lines =
+ except ModuleNotFoundError:
except ImportError:
pass
import

ADD
changelog/2691.removal.rst
+Deprecated ``urllib3.contrib.pyopenssl`` module which will be removed in future urllib3 v2.x release.
\ No newline at end of file

MODIFY
docs/reference/contrib/pyopenssl.rst
docs/reference/contrib/pyopenssl.rst
PyOpenSSL
=========
+.. warning::
+ DEPRECATED: This module is deprecated and will be removed in a future 2.x release.
+ Read more in this `issue <https://github.com/urllib3/urllib3/issues/2680>`_.
.. automodule:: urllib3.contrib.pyopenssl
:members:

MODIFY
pyproject.toml
pyproject.toml
@@ -50,6 +50,7 @@ secure = [
"cryptography>=1.3.4",
"idna>=2.0.0",
"certifi",
+ "urllib3-secure-extra",
]
socks = [
"PySocks>=1.5.6,<2.0,!=1.5.7",

MODIFY
src/urllib3/__init__.py
src/urllib3/__init__.py
@@ -20,6 +20,23 @@ from .util.request import make_headers
from .util.retry import Retry
from .util.timeout import Timeout
+# === NOTE TO REPACKAGERS AND VENDORS ===
+# Please delete this block, this logic is only
+# for urllib3 being distributed via PyPI.
+# See: https://github.com/urllib3/urllib3/issues/2680
+try:
+ import urllib3_secure_extra # type: ignore # noqa: F401
+except ModuleNotFoundError:
+ pass
+else:
+ warnings.warn(
+ "'urllib3[secure]' extra is deprecated and will be removed "
+ "in a future release of urllib3 2.x. Read more in this issue: "
+ "https://github.com/urllib3/urllib3/issues/2680",
+ category=DeprecationWarning,
+ stacklevel=2,
+ )
+
__author__ = "Andrey Petrov (andrey.petrov@shazow.net)"
__license__ = "MIT"
__version__ = __version__

MODIFY
src/urllib3/contrib/pyopenssl.py
src/urllib3/contrib/pyopenssl.py
@@ -53,6 +53,7 @@ except ImportError:
import logging
import ssl
+import warnings
from io import BytesIO
from socket import socket as socket_cls
from socket import timeout
@@ -60,6 +61,14 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from .. import util
+warnings.warn(
+ "'urllib3.contrib.pyopenssl' module is deprecated and will be removed "
+ "in a future release of urllib3 2.x. Read more in this issue: "
+ "https://github.com/urllib3/urllib3/issues/2680",
+ category=DeprecationWarning,
+ stacklevel=2,
+)
+
if TYPE_CHECKING:
from OpenSSL.crypto import CRL, X509 # type: ignore[import]

Add deprecation warnings for pyOpenSSL and the [secure] extra

Co-authored-by: Seth Michael Larson <sethmichaellarson@gmail.com>