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
Allow custom chunksizes in dns.rdata.to_text #617
Conversation
Codecov Report
@@ Coverage Diff @@
## master #617 +/- ##
==========================================
+ Coverage 97.81% 97.89% +0.07%
==========================================
Files 121 121
Lines 10081 10083 +2
==========================================
+ Hits 9861 9871 +10
+ Misses 220 212 -8
Continue to review full report at Codecov.
|
This doesn't quite work, as all keywords passed to rdata's to_text are passed to _hexify or _base64ify, so if you passed a parameter 'foo' as well as 'chunksize' you'd get: TypeError: _hexify() got an unexpected keyword argument 'foo' Probably the easiest thing is to make _hexify and _base64ify have a **kw parameter to soak up any unknown rdata keywords that are not relevant to them. |
I added a fixup commit. Once the PR has settled on the way to go, I'll squash it. Edit: done. |
ee896a9
to
a927fa3
Compare
Almost ready to merge this, but after having a second set of eyes review we noticed that the changes in a927fa3 are doing _hexify(..., chunksize=kw.get('chunksize', 128)) Instead of just passing **kw like the invocations of _hexify() and _base64ify() in 18feb95. Fix that and squash it and we're good to merge. /Bob |
Done. The calls you pointed out previously had hardcoded The new approach is to I also added There are 4 calls of |
I believe that this change introduces a new problem, as it's modifying kwargs. With code like:
the first record would be converted with chunksize=100, and the second one would not, as chunksize has been removed from kwargs. This would be unexpected, to say the least. As far as I can tell, there are 3 separate cases - types that have a required chunk size, types that use the default, and types that override the default, but should still be configurable. In the first two, a user-provided value should take precedence, and in the last one, a user-provided value should be ignored. One solution to this would be to have (potentially) 4 different chunk size parameters that I'm wondering if this shouldn't be punted to post-2.1.0, to allow more time to come up with a better solution. |
I now added This PR, which is a simple extension of the current behavior, does not introduce any incompatibility or forestall any future changes regarding the treatment of default My impression is that the benefit from the usability improvement in itself justifies making the change. |
Merged, thanks! |
This implements #612 not only for (C)DNSKEY (as discussed there), but also for all other occurrences of
_base64ify
and_hexify
inside any of thedns.rdata.to_text()
methods.I added a comprehensive test for the DNSKEY case, but did not explicitly add tests for other record types. If more tests should be added, I'd require some guidance how to avoid the bloat. (I noticed that you have examples in e.g.
tests/example1.good
, but as the new tests apply various chunk sizes, I wasn't sure if writing out all variations into a static file would be the best approach.)Fixes #612.