fix issue with getcode not being available in Py2.4 yet

fix for Python 2.4 compatibility issue that got merged in with #1066
(cc @JensTimmerman)