Fix conflicted declarations of tp_write
Move string assertions to functions instead of macros.