Skip to content

[BUG] Passing non-bytes file input leads to error #2198

@Bibo-Joshi

Description

@Bibo-Joshi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions