Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an issue where replacing callback_data in InlineKeyboardButtons (when arbitrary_callback_data is enabled) drops other button attributes by cloning the original button before mutation.
Changes:
- Update
CallbackDataCache.process_keyboardtodeepcopybuttons before updatingcallback_data. - Extend the callback data cache test to assert preservation of non-
callback_dataattributes. - Add an unreleased changelog entry for the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/ext/test_callbackdatacache.py | Adds assertions to verify additional InlineKeyboardButton attributes are preserved after callback_data replacement. |
| src/telegram/ext/_callbackdatacache.py | Clones buttons before modifying callback_data to preserve all original button attributes. |
| changes/unreleased/5159.oRWyrKjKtGSS28NxvnJnCy.toml | Adds an unreleased note describing the behavior change/fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the bug as reported in https://t.me/pythontelegrambotgroup/789176
This bug only happened when the user had arbitrary_callback_data enabled.
I used a deepcopy instead of adding more arguments during initialization so we don't have to touch the file for future new arguments.