Merge pull request #5424 from acozzette/mac-python-fix

Cherry-picked fix from #5406