eternnoir / pyTelegramBotAPI

Python Telegram bot api.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in pip library

Visoff opened this issue · comments

commented

I'm using (what pip says) the latest version of telebot(4.19.1) with python 3.11 and pip 24.0, but I was getting some strange errors related to message json parsing in types.py of telebot source, I went to github and pulled a copy to my machince, everything seemed to work fine, then I checked $path_to_python_venv/lib/..../telebot/types.py and found that at least on de_json function was different from what I've seen in github repo, it was de_json and init methods related to UsersShared class, starting at line 9135 of types.py file

Methods in github:

    @classmethod
    def de_json(cls, json_string):
        if json_string is None: return None
        obj = cls.check_json(json_string)
        obj['users'] = [SharedUser.de_json(user) for user in obj['users']]
        return cls(**obj)

    def __init__(self, request_id, users: List[SharedUser], **kwargs):
        self.request_id = request_id
        self.users = users

Methods in pip library:

    @classmethod
    def de_json(cls, json_string):
        if json_string is None: return None
        obj = cls.check_json(json_string)
        obj['user_ids'] = [SharedUser.de_json(user) for user in obj['user_ids']]
        return cls(**obj)

    def __init__(self, request_id, user_ids: List[SharedUser], **kwargs):
        self.request_id = request_id
        self.user_ids = user_ids
commented

This was probably a bug

commented

Yeah, probably, but I ran into it even after reinstalling library and I was getting it even in docker container so it could be related to library configurations in pip registery. Also, this "bug" crashes the whole app if it sees message with shared_users and some dude could crash every telebot app by sending some person to the chat with it so it's quite dangerous

commented

You will need to install github version as told in the readme then, NOT using pip.
@Badiboy the recent version 4.19.1 does not contain the fix, does it?

commented

The catch is that in this github repo in /telebot/version.py it says 4.19.1 and package version is also 4.19.1 but code is different.

And this version(from repo) contains the fix, it's fine, I modified my local library and it worked but the situation, where I could crash any telebot app scares me

commented

Only bots using users shared are affected, no? Seems like if you do not have a button to share users, you are not affected, so you will not be able to crash most of telebot bots.

commented

And it is not a catch.
Versions are updated before release.

commented

Oh, I wrongly assumed that you are able to send this type of messages freely, like contacts...

So pip just lies to us like that? By displaying the version that is technically not released yet

commented

Oh, I just found how version tracking actually works here

Tysm for your time, explanation and solution

@Badiboy the recent version 4.19.1 does not contain the fix, does it?

It does not. SharedUsers were fixed later. I'll try to push 14.19.2 update.