you are right. Python just prints an error in this case. Below some Python code for completeness to handle the case when no environment texture has been assigned:
import Rhino
def ZRotateCurrentEnvironment(deg=0.0):
# get current environment
env = Rhino.Render.RenderEnvironment.CurrentEnvironment
if not env: return None
# get environment texture
tex = env.FindChild("Texture")
if not tex: return None
# rotate environment
context = Rhino.Render.RenderContent.ChangeContexts.UI
tex.SetRotation(Rhino.Geometry.Vector3d(0.0, 0.0, deg), context)
print "Current rotation = {}".format(tex.GetRotation().Z)
if __name__=="__main__":
ZRotateCurrentEnvironment(90)
c.