Fix traceback when generating BSD grains

This fixes a traceback introduced in e72876b which causes grain
compilation to be incomplete. Fixes #6407.
Only split on basestring types