Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(64065)

Unified Diff: Modules/hashlib.h

Issue 26798: add BLAKE2 to hashlib
Patch Set: Created 3 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Modules/_blake2/impl/blake2s-round.h ('k') | PCbuild/pythoncore.vcxproj » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
index 358045364cbc8370150398142302943b82ad7ba6..530b6b1723cef0dd30368ecfdffe52d2bc97d4ab 100644
--- a/Modules/hashlib.h
+++ b/Modules/hashlib.h
@@ -2,30 +2,33 @@
/*
* Given a PyObject* obj, fill in the Py_buffer* viewp with the result
- * of PyObject_GetBuffer. Sets an exception and issues a return NULL
- * on any errors.
+ * of PyObject_GetBuffer. Sets an exception and issues the erraction
+ * on any errors, e.g. 'return NULL' or 'goto error'.
*/
-#define GET_BUFFER_VIEW_OR_ERROUT(obj, viewp) do { \
+#define GET_BUFFER_VIEW_OR_ERROR(obj, viewp, erraction) do { \
if (PyUnicode_Check((obj))) { \
PyErr_SetString(PyExc_TypeError, \
"Unicode-objects must be encoded before hashing");\
- return NULL; \
+ erraction; \
} \
if (!PyObject_CheckBuffer((obj))) { \
PyErr_SetString(PyExc_TypeError, \
"object supporting the buffer API required"); \
- return NULL; \
+ erraction; \
} \
if (PyObject_GetBuffer((obj), (viewp), PyBUF_SIMPLE) == -1) { \
- return NULL; \
+ erraction; \
} \
if ((viewp)->ndim > 1) { \
PyErr_SetString(PyExc_BufferError, \
"Buffer must be single dimension"); \
PyBuffer_Release((viewp)); \
- return NULL; \
+ erraction; \
} \
- } while(0);
+ } while(0)
+
+#define GET_BUFFER_VIEW_OR_ERROUT(obj, viewp) \
+ GET_BUFFER_VIEW_OR_ERROR(obj, viewp, return NULL)
/*
* Helper code to synchronize access to the hash object when the GIL is
« no previous file with comments | « Modules/_blake2/impl/blake2s-round.h ('k') | PCbuild/pythoncore.vcxproj » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+