_userid_internet_accessible uses string.index() which throws an ValueError if the token is not present. This should be changed to string.find() which returns -1 if the token is not found.
Reproduce
Have an S3 bucket policy with UserId value that does not contain a "*"