From Sdaji's reply: "Scare/bribe/embarrass/excite/hurt" - from what I take from that is maybe he's excited that you're there - or simply alert that something has changed in his cage - or maybe it's a sign of a little stress, or maybe he's reacting to a scent on your fingers. Did you wash your hands before approching him, or were you handling something else inbetween? (Patting the cat, etc) that could indicate that there's something he's locked onto with his senses?
Because snakes don't have eyelids and sleep/rest with their eyes open it's near impossible to tell if a snake is in the process of sleeping or resting and the general rule is that if a snake is curled up under it's hide or coiled in the open with its head tucked under a coil then it is considered to be sleeping/resting.
While Sdaji's reply makes good sense and there is the possibility that the snake was startled and became scared from being exposed it may also be a case of the snake's pupil adjusting to the change in the intensity of light when from coming out of darkness under the hide into daylight or a well lit room.
Work done by Brischoux, Pizzatto & Shine in 2010 "Insights into the adaptive significance of vertical pupil shape in snakes" provides, what I would describe as, a very reasonable evaluation why polyphasic species of snakes such as pythons are equipped with vertical pupils. A polyphasic species of snake is basically one that is active both day and night.
They identify that -
"On functional grounds, a variable‐aperture vertical pupil (i) allows a nocturnal species to have a sensitive retina for night vision but avoid dazzle by day by adjusting pupil closure, and (ii) increases visual acuity by day, because a narrow vertical pupil can project a sharper image onto the retina in the horizontal plane. Detection of horizontal movement may be critical for predators that wait in ambush for moving prey, suggesting that foraging mode (ambush predation) as well as polyphasic activity may favour the evolution of vertical pupil shape. Camouflage (disruption of the circular outline of the eye) also may be beneficial for ambush predators. A comparative analysis in snakes reveals significant functional links between pupil shape and foraging mode, as well as between pupil shape and diel timing of activity."
&
"Rather than enhancing visual acuity at low light levels, vertically slit pupils convey flexibility over aperture size (via facultative dilation) and hence increase the range of light intensities over which the eye can function effectively (especially important for species that are active both by day and by night:"