Fix handling for py3.