from http bugs python orgissue6717 a misbehaving trace hook can trigger a segfault by exceeding the recursion limit change to true to crash interpreter
import sys


def x():
    pass

def g(*args):
    if True: 
        try:
            x()
        except:
            pass
    return g

def f():
    print(sys.getrecursionlimit())
    f()

sys.settrace(g)

f()