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

Message.flags type asymetry #606

Closed
pspacek opened this issue Nov 23, 2020 · 3 comments
Closed

Message.flags type asymetry #606

pspacek opened this issue Nov 23, 2020 · 3 comments

Comments

@pspacek
Copy link
Collaborator

pspacek commented Nov 23, 2020

It seems that Message.flags attribute on messages produced by message.make_query() is EnumInt, but it is a plain int on answers from dns.resolver.resolve(). I'm not sure if this was intentional in 2.0 or not. If it is an omission (i.e. not omitted for compatibility reasons) I can prepare a PR to use EnumInt on responses as well.

Version: 49a75f4

Reproducer:

In [10]: q = dns.message.make_query('.', 'NS')

In [11]: q.flags
Out[11]: <Flag.RD: 256>
In [20]: import dns.message

In [21]: r = dns.resolver.resolve('.', 'NS')

In [22]: r.response.flags
Out[22]: 33152

In [23]: type(r.response.flags)
Out[23]: int

In [24]: dns.flags.Flag(r.response.flags)
Out[24]: <Flag.QR|RD|RA: 33152>
@rthalley
Copy link
Owner

Flags is not an enum value, it's just or'd up from enum values, so if anything a single flag should be a pure int not an EnumInt. But EnumInts are just subclasses of int, so it's fine as is I think.

@rthalley
Copy link
Owner

rthalley commented Jan 4, 2021

Brian points out you were right and I misunderstood, so reopening this. My apologies! Indeed it would be a good thing make appropriate Flag instances.

@rthalley
Copy link
Owner

rthalley commented Jan 4, 2021

I fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants