summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2017-09-07 23:45:07 (GMT)
committerGitHub <noreply@github.com>2017-09-07 23:45:07 (GMT)
commit611a3eab194dfd0a54e541e8e8547051df24bcfc (patch)
treec33877e9b68a2f24421cc18dd050a9da2813d855
parent82cae7c5be4175e2173e4d342825b5315a9d612a (diff)
downloadcpython-611a3eab194dfd0a54e541e8e8547051df24bcfc.zip
cpython-611a3eab194dfd0a54e541e8e8547051df24bcfc.tar.gz
cpython-611a3eab194dfd0a54e541e8e8547051df24bcfc.tar.bz2
[2.7] bpo-28958: Improve SSLContext error reporting. (GH-3414) (#3433)
Signed-off-by: Christian Heimes <christian@python.org> (cherry picked from commit 17c9ac9)
-rw-r--r--Misc/NEWS.d/next/Library/2017-09-06-19-41-01.bpo-28958.x4-K5F.rst2
-rw-r--r--Modules/_ssl.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Library/2017-09-06-19-41-01.bpo-28958.x4-K5F.rst b/Misc/NEWS.d/next/Library/2017-09-06-19-41-01.bpo-28958.x4-K5F.rst
new file mode 100644
index 0000000..eb4e206
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2017-09-06-19-41-01.bpo-28958.x4-K5F.rst
@@ -0,0 +1,2 @@
+ssl.SSLContext() now uses OpenSSL error information when a context cannot be
+instantiated.
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 761554a..5b4cec2 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -2146,8 +2146,7 @@ context_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
if (ctx == NULL) {
- PyErr_SetString(PySSLErrorObject,
- "failed to allocate SSL context");
+ _setSSLError(NULL, 0, __FILE__, __LINE__);
return NULL;
}