Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError in Str implementation #65

Open
3 tasks done
emv33 opened this issue Apr 17, 2024 · 0 comments
Open
3 tasks done

UnicodeDecodeError in Str implementation #65

emv33 opened this issue Apr 17, 2024 · 0 comments

Comments

@emv33
Copy link

emv33 commented Apr 17, 2024

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

There's a crash in message.text (which, btw, is not str - this is not stated in the documentation, which says message.text is a plain str)...

Steps to reproduce

Add the following message handler to the bot and then write this message anywhere the bot is:

🏳️‍🌈🏳️‍🌈

Code example

@app.on_message(group=-199)
async def test(client: pyrogram.client.Client, message: pyrogram.types.Message) -> None:
    print(message.text[:5])

Logs

[   dispatcher.py:342    handler_worker()] 'utf-16-le' codec can't decode bytes in position 10-11: unexpected end of data
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/pyrogram/dispatcher.py", line 329, in handler_worker
    await handler.callback(self.client, *args)
  File "/home/user/.local/lib/python3.10/site-packages/pyrogram/handlers/message_handler.py", line 151, in resolve_future_or_callback
    await self.original_callback(client, message, *args)
  File "/mnt/c/bot/handlers/test.py", line 38, in test
    print(message.text[:5])
  File "/home/user/.local/lib/python3.10/site-packages/pyrogram/types/messages_and_media/message.py", line 57, in __getitem__
    return parser_utils.remove_surrogates(parser_utils.add_surrogates(self)[item])
  File "/home/user/.local/lib/python3.10/site-packages/pyrogram/parser/utils.py", line 38, in remove_surrogates
    return text.encode("utf-16", "surrogatepass").decode("utf-16")
UnicodeDecodeError: 'utf-16-le' codec can't decode bytes in position 10-11: unexpected end of data
SpEcHiDe added a commit to TelegramPlayGround/pyrogram that referenced this issue Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant