brandon-rhodes/pyephem — pull request #5 by ludwigschwardt (2012-11-21 15:46:56+00:00)
Title: Be stricter when parsing angle strings

I've added extra error checking when parsing the string representation of angles in order to catch invalid strings.

A valid angle string now has the strict format of [number[:number[:number]]], which is 0 to 3 valid number strings separated by colons. If any number string is empty, it is replaced by the value 0. If any number string is non-empty but invalid, a ValueError is raised instead. This replaces the previous relaxed behaviour where the string parsing always succeeds and patently invalid strings like 'hello world' silently result in angles of 0.

An open question for me is whether the empty string '' should result in a ValueError or an angle of 0. My PR keeps the latter behaviour for compatibility but I favour the former.