Use basestring instead of (str, unicode)
More informative exceptions on invalid priority