diff options
author | Victor Stinner <vstinner@python.org> | 2023-06-06 21:17:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-06 21:17:45 (GMT) |
commit | 2587b9f64eefde803a5e0b050171ad5f6654f31b (patch) | |
tree | 5304fb7ff2534429db4b07a907f8c06cab0a19dc /Lib/urllib | |
parent | 94d5f9827da4bf4b1e61c134fe29904b2b92f124 (diff) | |
download | cpython-2587b9f64eefde803a5e0b050171ad5f6654f31b.zip cpython-2587b9f64eefde803a5e0b050171ad5f6654f31b.tar.gz cpython-2587b9f64eefde803a5e0b050171ad5f6654f31b.tar.bz2 |
gh-105382: Remove urllib.request cafile parameter (#105384)
Remove cafile, capath and cadefault parameters of the
urllib.request.urlopen() function, deprecated in Python 3.6.
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 5314b3f..1d03259 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -136,7 +136,7 @@ __version__ = '%d.%d' % sys.version_info[:2] _opener = None def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, - *, cafile=None, capath=None, cadefault=False, context=None): + *, context=None): '''Open the URL url, which can be either a string or a Request object. *data* must be an object specifying additional data to be sent to @@ -154,14 +154,6 @@ def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, If *context* is specified, it must be a ssl.SSLContext instance describing the various SSL options. See HTTPSConnection for more details. - The optional *cafile* and *capath* parameters specify a set of trusted CA - certificates for HTTPS requests. cafile should point to a single file - containing a bundle of CA certificates, whereas capath should point to a - directory of hashed certificate files. More information can be found in - ssl.SSLContext.load_verify_locations(). - - The *cadefault* parameter is ignored. - This function always returns an object which can work as a context manager and has the properties url, headers, and status. @@ -187,25 +179,7 @@ def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, ''' global _opener - if cafile or capath or cadefault: - import warnings - warnings.warn("cafile, capath and cadefault are deprecated, use a " - "custom context instead.", DeprecationWarning, 2) - if context is not None: - raise ValueError( - "You can't pass both context and any of cafile, capath, and " - "cadefault" - ) - if not _have_ssl: - raise ValueError('SSL support not available') - context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, - cafile=cafile, - capath=capath) - # send ALPN extension to indicate HTTP/1.1 protocol - context.set_alpn_protocols(['http/1.1']) - https_handler = HTTPSHandler(context=context) - opener = build_opener(https_handler) - elif context: + if context: https_handler = HTTPSHandler(context=context) opener = build_opener(https_handler) elif _opener is None: |