Fixed doctest patch to work on both Python2 and Python3.