https://t.me/pythontelegrambotgroup/396541
TL;DR:
send_document(open('text_file', 'rb')) works but send_document(open('text_file', 'r')) raises is error.
This is, because we try to guess if the file is an image using imghdr.what(None, stream) in InputFile.is_image, which only works if stream is a bytes stream.
If I comment the is_image out, the file is sent without issue, so I guess we should just check if the input is bytes before calling is_image