Skip to content

Instantly share code, notes, and snippets.

@sbp
Last active November 11, 2015 12:01
Show Gist options
  • Save sbp/1067cd7047486832ea76 to your computer and use it in GitHub Desktop.
Save sbp/1067cd7047486832ea76 to your computer and use it in GitHub Desktop.
Patch to make simplesha3 (Version 20150922) Python 3 compatible
$ diff -Naur simplesha3.djb.c simplesha3.c
--- simplesha3.djb.c 2015-09-22 11:28:31.000000000 +0100
+++ simplesha3.c 2015-11-11 11:59:16.000000000 +0000
@@ -11,7 +11,7 @@
int n; \
if (!PyArg_ParseTuple(args,"s#:update",&m,&n)) return 0; \
Keccak(r*8,m,n,p,h,d); \
- return PyString_FromStringAndSize((const char *)h,d); \
+ return PyBytes_FromStringAndSize((const char *)h,d); \
} \
PyDoc_STRVAR(i##_doc,"Return the "name" digest of the input string.");
@@ -49,7 +49,9 @@
{0,0}
};
-PyMODINIT_FUNC initsimplesha3(void)
+PyMODINIT_FUNC PyInit_simplesha3(void)
{
- Py_InitModule("simplesha3",functions);
+ static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT, "simplesha3", "simplesha3", -1, functions, };
+ PyModule_Create(&moduledef);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment