diff --git a/src/bindings/swig/hammer.i b/src/bindings/swig/hammer.i
index f784f31e7c69bb9341d8f01410cd3fcedf3fae03..bef82b9d3321faa46686871a5474eec37c4073ba 100644
--- a/src/bindings/swig/hammer.i
+++ b/src/bindings/swig/hammer.i
@@ -1,7 +1,16 @@
 %module hammer
 
-%include "typemaps.i"
 %include "stdint.i"
+%include "typemaps.i"
+%apply char [ANY] { uint8_t [ANY] };
+
+#if defined(SWIGPYTHON)
+%typemap(in) uint8_t* {
+  $1 = (uint8_t*)PyString_AsString($input);
+ }
+#else
+  #warning no "in" typemap defined
+#endif
 
  // All the include paths are relative to the build, i.e., ../../. If you need to build these manually (i.e., not with scons), keep that in mind.
 %{
@@ -12,5 +21,5 @@
 %include "allocator.h"
 %include "hammer.h"
 
-%apply const char* { const uint8_t* }
+