Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e39bba2

Browse files
committed
merge 3.4 (#22960)
2 parents 3a9c68e + c1da3d1 commit e39bba2

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

Doc/library/xmlrpc.client.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ between conformable Python objects and XML on the wire.
2727
constructed data. If you need to parse untrusted or unauthenticated data see
2828
:ref:`xml-vulnerabilities`.
2929

30-
.. versionchanged:: 3.4.3
30+
.. versionchanged:: 3.5
3131

3232
For https URIs, :mod:`xmlrpc.client` now performs all the necessary
3333
certificate and hostname checks by default
3434

3535
.. class:: ServerProxy(uri, transport=None, encoding=None, verbose=False, \
3636
allow_none=False, use_datetime=False, \
37-
use_builtin_types=False)
37+
use_builtin_types=False, context=None)
3838

3939
.. versionchanged:: 3.3
4040
The *use_builtin_types* flag was added.
@@ -63,7 +63,9 @@ between conformable Python objects and XML on the wire.
6363
portion will be base64-encoded as an HTTP 'Authorization' header, and sent to
6464
the remote server as part of the connection process when invoking an XML-RPC
6565
method. You only need to use this if the remote server requires a Basic
66-
Authentication user and password.
66+
Authentication user and password. If an HTTPS url is provided, *context* may
67+
be :class:`ssl.SSLContext` and configures the SSL settings of the underlying
68+
HTTPS connection.
6769

6870
The returned instance is a proxy object with methods that can be used to invoke
6971
corresponding RPC calls on the remote server. If the remote server supports the
@@ -127,6 +129,9 @@ between conformable Python objects and XML on the wire.
127129
:class:`Server` is retained as an alias for :class:`ServerProxy` for backwards
128130
compatibility. New code should use :class:`ServerProxy`.
129131

132+
.. versionchanged:: 3.5
133+
Added the *context* argument.
134+
130135

131136
.. seealso::
132137

Lib/xmlrpc/client.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,11 @@ def parse_response(self, response):
13241324
class SafeTransport(Transport):
13251325
"""Handles an HTTPS transaction to an XML-RPC server."""
13261326

1327+
def __init__(self, use_datetime=False, use_builtin_types=False, *,
1328+
context=None):
1329+
super().__init__(use_datetime=use_datetime, use_builtin_types=use_builtin_types)
1330+
self.context = context
1331+
13271332
# FIXME: mostly untested
13281333

13291334
def make_connection(self, host):
@@ -1337,7 +1342,7 @@ def make_connection(self, host):
13371342
# host may be a string, or a (host, x509-dict) tuple
13381343
chost, self._extra_headers, x509 = self.get_host_info(host)
13391344
self._connection = host, http.client.HTTPSConnection(chost,
1340-
None, **(x509 or {}))
1345+
None, context=self.context, **(x509 or {}))
13411346
return self._connection[1]
13421347

13431348
##
@@ -1380,7 +1385,8 @@ class ServerProxy:
13801385
"""
13811386

13821387
def __init__(self, uri, transport=None, encoding=None, verbose=False,
1383-
allow_none=False, use_datetime=False, use_builtin_types=False):
1388+
allow_none=False, use_datetime=False, use_builtin_types=False,
1389+
*, context=None):
13841390
# establish a "logical" server connection
13851391

13861392
# get the url
@@ -1394,10 +1400,13 @@ def __init__(self, uri, transport=None, encoding=None, verbose=False,
13941400
if transport is None:
13951401
if type == "https":
13961402
handler = SafeTransport
1403+
extra_kwargs = {"context": context}
13971404
else:
13981405
handler = Transport
1406+
extra_kwargs = {}
13991407
transport = handler(use_datetime=use_datetime,
1400-
use_builtin_types=use_builtin_types)
1408+
use_builtin_types=use_builtin_types,
1409+
**extra_kwargs)
14011410
self.__transport = transport
14021411

14031412
self.__encoding = encoding or 'utf-8'

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ Core and Builtins
191191
Library
192192
-------
193193

194+
- Issue #22960: Add a context argument to xmlrpclib.ServerProxy constructor.
195+
194196
- Issue #22389: Add contextlib.redirect_stderr().
195197

196198
- Issue #21356: Make ssl.RAND_egd() optional to support LibreSSL. The

0 commit comments

Comments
 (0)