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

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


Author: victor.stinner
Date: Sun May 16 23:23:48 2010
New Revision: 81237
Log:
Issue #8477: _ssl._test_decode_cert() supports str with surrogates and bytes
for the filename
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:23:48 2010
@@ -363,6 +363,9 @@
 Library
 -------
 
+- Issue #8477: _ssl._test_decode_cert() supports str with surrogates and bytes
+ for the filename
+
 - Issue #8550: Add first class ``SSLContext`` objects to the ssl module.
 
 - Issue #8681: Make the zlib module's error messages more informative when
Modified: python/branches/py3k/Modules/_ssl.c
==============================================================================
--- python/branches/py3k/Modules/_ssl.c	(original)
+++ python/branches/py3k/Modules/_ssl.c	Sun May 16 23:23:48 2010
@@ -811,13 +811,13 @@
 PySSL_test_decode_certificate (PyObject *mod, PyObject *args) {
 
 PyObject *retval = NULL;
- char *filename = NULL;
+ PyObject *filename;
 X509 *x=NULL;
 BIO *cert;
 int verbose = 1;
 
- if (!PyArg_ParseTuple(args, "s|i:test_decode_certificate",
- &filename, &verbose))
+ if (!PyArg_ParseTuple(args, "O&|i:test_decode_certificate",
+ PyUnicode_FSConverter, &filename, &verbose))
 return NULL;
 
 if ((cert=BIO_new(BIO_s_file())) == NULL) {
@@ -826,7 +826,7 @@
 goto fail0;
 }
 
- if (BIO_read_filename(cert,filename) <= 0) {
+ if (BIO_read_filename(cert, PyBytes_AsString(filename)) <= 0) {
 PyErr_SetString(PySSLErrorObject,
 "Can't open file");
 goto fail0;
@@ -842,7 +842,7 @@
 retval = _decode_certificate(x, verbose);
 
 fail0:
-
+ Py_DECREF(filename);
 if (cert != NULL) BIO_free(cert);
 return retval;
 }


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /