Fix segfault on Python 3