summaryrefslogtreecommitdiffstats
path: root/Lib/poplib.py
diff options
context:
space:
mode:
authorGiampaolo RodolĂ  <g.rodola@gmail.com>2010-08-17 16:09:53 (GMT)
committerGiampaolo RodolĂ  <g.rodola@gmail.com>2010-08-17 16:09:53 (GMT)
commit42382fedccf1306c09055b68c0b67351118f8065 (patch)
treee92e9f677adda02bbfb194aabfe3dc0e4eabe584 /Lib/poplib.py
parentccfb91c89f9d7515356f31fff4af4c5cbd5eef7a (diff)
downloadcpython-42382fedccf1306c09055b68c0b67351118f8065.zip
cpython-42382fedccf1306c09055b68c0b67351118f8065.tar.gz
cpython-42382fedccf1306c09055b68c0b67351118f8065.tar.bz2
fix issue #8807: adds a context parameter to POP3_SSL class.
Diffstat (limited to 'Lib/poplib.py')
-rw-r--r--Lib/poplib.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/Lib/poplib.py b/Lib/poplib.py
index 1a529d0..84ea88d 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -331,16 +331,26 @@ else:
See the methods of the parent class POP3 for more documentation.
"""
- def __init__(self, host, port=POP3_SSL_PORT,
- keyfile=None, certfile=None,
- timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
+ def __init__(self, host, port=POP3_SSL_PORT, keyfile=None, certfile=None,
+ timeout=socket._GLOBAL_DEFAULT_TIMEOUT, context=None):
+ if context is not None and keyfile is not None:
+ raise ValueError("context and keyfile arguments are mutually "
+ "exclusive")
+ if context is not None and certfile is not None:
+ raise ValueError("context and certfile arguments are mutually "
+ "exclusive")
self.keyfile = keyfile
self.certfile = certfile
+ self.context = context
POP3.__init__(self, host, port, timeout)
def _create_socket(self, timeout):
sock = POP3._create_socket(self, timeout)
- return ssl.wrap_socket(sock, self.keyfile, self.certfile)
+ if self.context is not None:
+ sock = self.context.wrap_socket(sock)
+ else:
+ sock = ssl.wrap_socket(sock, self.keyfile, self.certfile)
+ return sock
__all__.append("POP3_SSL")