]> granicus.if.org Git - python/commitdiff
Refuse to compute digests from PyUnicode (str) instances.
authorGuido van Rossum <guido@python.org>
Wed, 29 Aug 2007 14:21:45 +0000 (14:21 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 29 Aug 2007 14:21:45 +0000 (14:21 +0000)
This breaks a few things that I'll patch up in a minute.

Modules/_hashopenssl.c

index 9ee1b3db278d1a3d3d2ec18a2ebb2f22b6208718..ad38cfdec12ae53701cb71600f2560297d84e292 100644 (file)
@@ -153,12 +153,12 @@ EVP_hexdigest(EVPobject *self, PyObject *unused)
 }
 
 #define MY_GET_BUFFER_VIEW_OR_ERROUT(obj, viewp) do { \
-                if (!PyObject_CheckBuffer((obj))) { \
+                if (PyUnicode_Check(obj) || !PyObject_CheckBuffer((obj))) { \
                     PyErr_SetString(PyExc_TypeError, \
                                     "object supporting the buffer API required"); \
                     return NULL; \
                 } \
-                if (PyObject_GetBuffer((obj), (viewp), PyBUF_CHARACTER) == -1) { \
+                if (PyObject_GetBuffer((obj), (viewp), PyBUF_SIMPLE) == -1) { \
                     return NULL; \
                 } \
                 if ((viewp)->ndim > 1) { \