fix(statuses): prevent dynamic changes to `keyword_args`

The use of `locals()` in status_reply caused issues due to its dynamic nature.  When `user_id = self.__get_logged_in_id()` was executed, `locals()` dynamically updated `keyword_args` to include the `self` reference again, even after it was explicitly deleted.  This led to a TypeError: `Mastodon.status_post() got multiple values for argument 'self'`.

This commit resolves the issue by replacing `keyword_args = locals()` with `keyword_args = locals().copy()`.  By creating a static copy of the local variables at the time of execution, it prevents unintended modifications caused by dynamic changes to the local scope.

Fixed #388
pull/389/head
Nano 2024-11-22 18:02:48 +08:00 zatwierdzone przez GitHub
rodzic 47aa316c36
commit 02dd7967cb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 1 dodań i 1 usunięć

Wyświetl plik

@ -332,7 +332,7 @@ class Mastodon(Internals):
are replying to, removing every other mentioned user from the
conversation.
"""
keyword_args = locals()
keyword_args = locals().copy()
del keyword_args["self"]
del keyword_args["to_status"]
del keyword_args["untag"]