Repository navigation
Render unnamed flag bits in flags.to_text() instead of dropping them - #1276
Merged
Merged
Conversation
Closes rthalley#1264. dns.flags.to_text() and dns.flags.edns_to_text() iterated only the named enum members, so any set bit without a named flag (for example the EDNS 0x2000 bit) was silently dropped from the text representation. Such bits are now rendered as FLAGn, where n is the bit position, and from_text() and edns_from_text() parse that form back, so the conversions round-trip. Adds tests in tests/test_flags.py and a whatsnew entry.
Owner
|
Thanks! |
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.
Closes #1264.
dns.flags.to_text()anddns.flags.edns_to_text()only iterated the named enum members, so any set bit without a named flag was silently dropped. For example,edns_to_text(0x2000)returned''andedns_to_text(DO | 0x2000)returned'DO', hiding the unknown bit.Unnamed bits are now rendered as
FLAGn, where n is the bit position, andfrom_text()/edns_from_text()parse that form back, so the conversions round-trip:This mirrors how dnspython already renders other unknown protocol values (e.g.
TYPEnnnnfor unknown RR types). Tests are added intests/test_flags.pyand awhatsnewentry is included.A small design note: I went with
FLAGn(bit position) for the token. Happy to switch to another representation if you would prefer one, since you mentioned wanting to ponder the format.