make compatible with python2.6

patch from https://gist.github.com/edufelipe/1027906