Encoder.unencode should check whether the given word is in the code

Issue #58 resolved
Johan Rosenkilde created an issue

I no longer remember if it was exactly this question, or a related question, but I remember distinctly in Lyon that we agreed that better-safe-than-sorry, and that the user should optionally be allowed to disable safety.

In the same spirit, Encoder.unencode should check that the given word is in the code before unencoding. An optional argument nocheck=False should allow one to bypass the check for speed.

Programmatically, this is best achieved by having a default implementation in Encoder.unencode which calls Encoder.unencode_nocheck when the check has been performed. This is the method that sub-classes usually overload (so they don't need to reimplement the check).

Comments (2)

  1. Johan Rosenkilde reporter

    Hmm, the new Encoder.unencode doesn't seem to return the message when nocheck==False?!

    Btw.: You can also make a test that calling Encoder.unencode(c,nocheck=True) doesn't throw an exception when c is not a codeword.

  2. Log in to comment