Update hooks.py

python2.4 compat for hooks.py