Error will occur when using sendDocument/sendAudio/...etc with non-ASCII filename.
The underlying cause is that the function format_header_param() in "requests/packages/urllib3/fields.py" (from library requests) is using an old way "RFC 2231" to handle non-ASCII character for the content-disposition of multipart/form-data. However, telegram bot API seem aborted this way and accept the utf-8 charater directly.
The way I solve this issue is changing the body of format_header_param() from
...
value = email.utils.encode_rfc2231(value, 'utf-8')
value = '%s*=%s' % (name, value)
...
to
value = '%s=%s' % (name, value)
Obviously, it is not a perfect way to tackle the problem since it may affect other process to use library requests
Error will occur when using sendDocument/sendAudio/...etc with non-ASCII filename. The underlying cause is that the function format_header_param() in "requests/packages/urllib3/fields.py" (from library requests) is using an old way "RFC 2231" to handle non-ASCII character for the content-disposition of multipart/form-data. However, telegram bot API seem aborted this way and accept the utf-8 charater directly.
The way I solve this issue is changing the body of format_header_param() from
to
Obviously, it is not a perfect way to tackle the problem since it may affect other process to use library requests