Commit b4e2f76d authored by Neal Norwitz's avatar Neal Norwitz

Use unicode

parent a369c5ab
...@@ -444,7 +444,7 @@ SHA256_hexdigest(SHAobject *self, PyObject *unused) ...@@ -444,7 +444,7 @@ SHA256_hexdigest(SHAobject *self, PyObject *unused)
unsigned char digest[SHA_DIGESTSIZE]; unsigned char digest[SHA_DIGESTSIZE];
SHAobject temp; SHAobject temp;
PyObject *retval; PyObject *retval;
char *hex_digest; Py_UNICODE *hex_digest;
int i, j; int i, j;
/* Get the raw (binary) digest value */ /* Get the raw (binary) digest value */
...@@ -452,10 +452,10 @@ SHA256_hexdigest(SHAobject *self, PyObject *unused) ...@@ -452,10 +452,10 @@ SHA256_hexdigest(SHAobject *self, PyObject *unused)
sha_final(digest, &temp); sha_final(digest, &temp);
/* Create a new string */ /* Create a new string */
retval = PyString_FromStringAndSize(NULL, self->digestsize * 2); retval = PyUnicode_FromStringAndSize(NULL, self->digestsize * 2);
if (!retval) if (!retval)
return NULL; return NULL;
hex_digest = PyString_AsString(retval); hex_digest = PyUnicode_AS_UNICODE(retval);
if (!hex_digest) { if (!hex_digest) {
Py_DECREF(retval); Py_DECREF(retval);
return NULL; return NULL;
......
...@@ -510,7 +510,7 @@ SHA512_hexdigest(SHAobject *self, PyObject *unused) ...@@ -510,7 +510,7 @@ SHA512_hexdigest(SHAobject *self, PyObject *unused)
unsigned char digest[SHA_DIGESTSIZE]; unsigned char digest[SHA_DIGESTSIZE];
SHAobject temp; SHAobject temp;
PyObject *retval; PyObject *retval;
char *hex_digest; Py_UNICODE *hex_digest;
int i, j; int i, j;
/* Get the raw (binary) digest value */ /* Get the raw (binary) digest value */
...@@ -518,10 +518,10 @@ SHA512_hexdigest(SHAobject *self, PyObject *unused) ...@@ -518,10 +518,10 @@ SHA512_hexdigest(SHAobject *self, PyObject *unused)
sha512_final(digest, &temp); sha512_final(digest, &temp);
/* Create a new string */ /* Create a new string */
retval = PyString_FromStringAndSize(NULL, self->digestsize * 2); retval = PyUnicode_FromStringAndSize(NULL, self->digestsize * 2);
if (!retval) if (!retval)
return NULL; return NULL;
hex_digest = PyString_AsString(retval); hex_digest = PyUnicode_AS_UNICODE(retval);
if (!hex_digest) { if (!hex_digest) {
Py_DECREF(retval); Py_DECREF(retval);
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment