If I open my interpreter 3.8, 3.9, 3.10 and enter this
print(inspect.getmodule(inspect.currentframe()))
It always prints None. Under some other circumstances which I did not figure out yet, it may (correctly) return
sys.modules["__main__"].
Can somebody please explain what is the correct behavior?