While in practice sys.modules has __main__ module, the purpose of PyC_MainModule_Backup/Restore is to temporarily override __main__. Running code outside of the text editor (callbacks for timers for e.g.) could remove the __main__ module which would then crash when running a script from the text editor.