Spherical / Custom projection at code level
I am not sure if it can be down in Python. But definitely possible in C.

Blender Cycles support non-planar lenses ala fisheye. You can find the user documentation for it on the wiki.

A walkthrough (and patch) from the developer who implemented this feature can be found on Dalai Felinto's website.