bug fix for TypeError: character mapping must return integer, None or unicode