[Python-checkins] r81239 - in python/branches/py3k: Misc/NEWS Modules/_ssl.c

victor.stinner python-checkins at python.org
Sun May 16 23:36:37 CEST 2010


Author: victor.stinner
Date: Sun May 16 23:36:37 2010
New Revision: 81239

Log:
Issue #8477: ssl.RAND_egd() supports str with surrogates and bytes for the path


Modified:
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/_ssl.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sun May 16 23:36:37 2010
@@ -363,8 +363,8 @@
 Library
 -------
 
-- Issue #8477: _ssl._test_decode_cert() supports str with surrogates and bytes
-  for the filename
+- Issue #8477: ssl.RAND_egd() and ssl._test_decode_cert() support str with
+  surrogates and bytes for the filename
 
 - Issue #8550: Add first class ``SSLContext`` objects to the ssl module.
 

Modified: python/branches/py3k/Modules/_ssl.c
==============================================================================
--- python/branches/py3k/Modules/_ssl.c	(original)
+++ python/branches/py3k/Modules/_ssl.c	Sun May 16 23:36:37 2010
@@ -1730,15 +1730,17 @@
 using the ssl() function.");
 
 static PyObject *
-PySSL_RAND_egd(PyObject *self, PyObject *arg)
+PySSL_RAND_egd(PyObject *self, PyObject *args)
 {
+    PyObject *path;
     int bytes;
 
-    if (!PyUnicode_Check(arg))
-        return PyErr_Format(PyExc_TypeError,
-                            "RAND_egd() expected string, found %s",
-                            Py_TYPE(arg)->tp_name);
-    bytes = RAND_egd(_PyUnicode_AsString(arg));
+    if (!PyArg_ParseTuple(args, "O&|i:RAND_egd",
+                          PyUnicode_FSConverter, &path))
+        return NULL;
+
+    bytes = RAND_egd(PyBytes_AsString(path));
+    Py_DECREF(path);
     if (bytes == -1) {
         PyErr_SetString(PySSLErrorObject,
                         "EGD connection failed or EGD did not return "
@@ -1767,7 +1769,7 @@
 #ifdef HAVE_OPENSSL_RAND
     {"RAND_add",            PySSL_RAND_add, METH_VARARGS,
      PySSL_RAND_add_doc},
-    {"RAND_egd",            PySSL_RAND_egd, METH_O,
+    {"RAND_egd",            PySSL_RAND_egd, METH_VARARGS,
      PySSL_RAND_egd_doc},
     {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
      PySSL_RAND_status_doc},


More information about the Python-checkins mailing list