Skip to content

Decode error correction code with dictionary - #80

Open
tim-tx wants to merge 1 commit into
za3k:masterfrom
tim-tx:fix-error-correction-indicator
Open

tim-tx wants to merge 1 commit into
za3k:masterfrom
tim-tx:fix-error-correction-indicator

Conversation

@tim-tx

@tim-tx tim-tx commented Jul 20, 2026

Copy link
Copy Markdown

In the note at the top of a PDF output indicating what qr-backup command you used to generate the document, the reported error correction code is wrong. For example, use the default M and the report will say you used --error-correction L. The reported value gets decoded by indexing the string LMQH but the qrcode module actually assigns

ERROR_CORRECT_L = 1
ERROR_CORRECT_M = 0
ERROR_CORRECT_Q = 3
ERROR_CORRECT_H = 2

see https://github.com/lincolnloop/python-qrcode/blob/main/qrcode/constants.py

The PR just decodes from a dictionary (i.e. by name) in case those values were to change.

@tim-tx

tim-tx commented Jul 22, 2026

Copy link
Copy Markdown
Author

Tests are failing because they compare hashes of PDF outputs to pre-calculated values. The PDF hashes could either be updated in the tests or the tests could be re-written to just compare restored data with original data.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant