I handle this by adding a scope check.
if utils.env.isPerspective(): # custom script
system.perspective.openPopup(...)
I handle this by adding a scope check.
if utils.env.isPerspective(): # custom script
system.perspective.openPopup(...)