Closed henrycjc closed 6 years ago
Many thanks for discovering and reporting this issue, especially also for the excellent reporting format.
The ndeflib.message_encoder
is not supposed to generate erroneous NDEF data and instead verify input data when record instances are created. Thus there is no need for an error handling strategy other than "strict", hence the input parameter not needed. This is different from ndeflib.message_decoder
which must potentially accept NDEF data with minor correctable errors (error strategy "relax") or gracefully skip or stop at uncorrectable errors (error strategy "ignore").
The problem you've found is a documentation error. Unfortunately it is within the function docstring and will require a new bugfix release 0.13.3
. I'll do that as soon as possible.
I have updated the documentation string with the erroneous example and released nfcpy 0.13.3 with that fix. Many thanks again for your report.
In order to support strict error reporting for NDEF data encoding, ndeflib exposes two helper methods:
message_decoder
andmessage_encoder
(see https://nfcpy.readthedocs.io/en/latest/modules/tag.html#nfc.tag.Tag.NDEF.records and https://ndeflib.readthedocs.io/en/stable/ndef.html#message-encoder) for more info.In the docs, the example code is as follows:
However,
message_encoder
does not accept the keyword argerrors
. Thus I have a few questions for @nehpetsde:Should / can
message_encoder
accept this keyword argument? Has this just yet to be implemented?Should
message_encoder
not support this keyword argument? If so, what limitations are associated with encoding that would mean it is not possible to support this?In the meantime, would you like me to create pull request updating the docs?
Error output:
Platform:
Lib version:
Python version: