Python 3 compatibility fix for signature calculation