Fix Python 3.x incompatibility in trace test