are you sure that m2secret doesn't just need bytes? Would ``value.encode('utf8')`` work?