A cohomological obstruction to weak approximation for homogeneous spaces