136136
137137_opener = None
138138def urlopen (url , data = None , timeout = socket ._GLOBAL_DEFAULT_TIMEOUT ,
139- * , cafile = None , capath = None , cadefault = False , context = None ):
139+ * , context = None ):
140140 '''Open the URL url, which can be either a string or a Request object.
141141
142142 *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,
154154 If *context* is specified, it must be a ssl.SSLContext instance describing
155155 the various SSL options. See HTTPSConnection for more details.
156156
157- The optional *cafile* and *capath* parameters specify a set of trusted CA
158- certificates for HTTPS requests. cafile should point to a single file
159- containing a bundle of CA certificates, whereas capath should point to a
160- directory of hashed certificate files. More information can be found in
161- ssl.SSLContext.load_verify_locations().
162-
163- The *cadefault* parameter is ignored.
164-
165157
166158 This function always returns an object which can work as a
167159 context manager and has the properties url, headers, and status.
@@ -187,25 +179,7 @@ def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
187179
188180 '''
189181 global _opener
190- if cafile or capath or cadefault :
191- import warnings
192- warnings .warn ("cafile, capath and cadefault are deprecated, use a "
193- "custom context instead." , DeprecationWarning , 2 )
194- if context is not None :
195- raise ValueError (
196- "You can't pass both context and any of cafile, capath, and "
197- "cadefault"
198- )
199- if not _have_ssl :
200- raise ValueError ('SSL support not available' )
201- context = ssl .create_default_context (ssl .Purpose .SERVER_AUTH ,
202- cafile = cafile ,
203- capath = capath )
204- # send ALPN extension to indicate HTTP/1.1 protocol
205- context .set_alpn_protocols (['http/1.1' ])
206- https_handler = HTTPSHandler (context = context )
207- opener = build_opener (https_handler )
208- elif context :
182+ if context :
209183 https_handler = HTTPSHandler (context = context )
210184 opener = build_opener (https_handler )
211185 elif _opener is None :
0 commit comments