summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-09 14:29:40 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-09 14:29:40 (GMT)
commit5ed033b5a21d56db0dbb0b2535b83afd5cad143d (patch)
treec71f90134e631b26ffe0507c139c3b070266c832 /Modules
parent867bcbcd6d7b251a2cd8a01ce70fdbc1dba6f029 (diff)
downloadcpython-5ed033b5a21d56db0dbb0b2535b83afd5cad143d.zip
cpython-5ed033b5a21d56db0dbb0b2535b83afd5cad143d.tar.gz
cpython-5ed033b5a21d56db0dbb0b2535b83afd5cad143d.tar.bz2
Change hashlib to return bytes from digest() instead of str8.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_hashopenssl.c4
-rw-r--r--Modules/sha256module.c6
-rw-r--r--Modules/sha512module.c6
3 files changed, 8 insertions, 8 deletions
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 98c91d1..47fc674 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -103,7 +103,7 @@ EVP_digest(EVPobject *self, PyObject *unused)
digest_size = EVP_MD_CTX_size(&temp_ctx);
EVP_DigestFinal(&temp_ctx, digest, NULL);
- retval = PyString_FromStringAndSize((const char *)digest, digest_size);
+ retval = PyBytes_FromStringAndSize((const char *)digest, digest_size);
EVP_MD_CTX_cleanup(&temp_ctx);
return retval;
}
@@ -133,7 +133,7 @@ EVP_hexdigest(EVPobject *self, PyObject *unused)
retval = PyString_FromStringAndSize(NULL, digest_size * 2);
if (!retval)
return NULL;
- hex_digest = PyString_AsString(retval);
+ hex_digest = PyString_AS_STRING(retval);
if (!hex_digest) {
Py_DECREF(retval);
return NULL;
diff --git a/Modules/sha256module.c b/Modules/sha256module.c
index 0effb07..f81608c 100644
--- a/Modules/sha256module.c
+++ b/Modules/sha256module.c
@@ -432,7 +432,7 @@ SHA256_digest(SHAobject *self, PyObject *unused)
SHAcopy(self, &temp);
sha_final(digest, &temp);
- return PyString_FromStringAndSize((const char *)digest, self->digestsize);
+ return PyBytes_FromStringAndSize((const char *)digest, self->digestsize);
}
PyDoc_STRVAR(SHA256_hexdigest__doc__,
@@ -510,9 +510,9 @@ static PyObject *
SHA256_get_name(PyObject *self, void *closure)
{
if (((SHAobject *)self)->digestsize == 32)
- return PyString_FromStringAndSize("SHA256", 6);
+ return PyUnicode_FromStringAndSize("SHA256", 6);
else
- return PyString_FromStringAndSize("SHA224", 6);
+ return PyUnicode_FromStringAndSize("SHA224", 6);
}
static PyGetSetDef SHA_getseters[] = {
diff --git a/Modules/sha512module.c b/Modules/sha512module.c
index 9f47b61..f2aae3a 100644
--- a/Modules/sha512module.c
+++ b/Modules/sha512module.c
@@ -498,7 +498,7 @@ SHA512_digest(SHAobject *self, PyObject *unused)
SHAcopy(self, &temp);
sha512_final(digest, &temp);
- return PyString_FromStringAndSize((const char *)digest, self->digestsize);
+ return PyBytes_FromStringAndSize((const char *)digest, self->digestsize);
}
PyDoc_STRVAR(SHA512_hexdigest__doc__,
@@ -576,9 +576,9 @@ static PyObject *
SHA512_get_name(PyObject *self, void *closure)
{
if (((SHAobject *)self)->digestsize == 64)
- return PyString_FromStringAndSize("SHA512", 6);
+ return PyUnicode_FromStringAndSize("SHA512", 6);
else
- return PyString_FromStringAndSize("SHA384", 6);
+ return PyUnicode_FromStringAndSize("SHA384", 6);
}
static PyGetSetDef SHA_getseters[] = {