Skip to content

Fix NameError on explicit --trim-5 value (mageck2-doc#1)#6

Merged
davidliwei merged 1 commit into
mainfrom
fix/trim5-nameerror
Jun 12, 2026
Merged

Fix NameError on explicit --trim-5 value (mageck2-doc#1)#6
davidliwei merged 1 commit into
mainfrom
fix/trim5-nameerror

Conversation

@davidliwei

Copy link
Copy Markdown
Owner

Problem

Reported in mageck2-doc#1 (Nov 2023). Running mageck2 count with an explicit numeric --trim-5 (e.g. --trim-5 20) crashes:

NameError: name 'candidate_trim5' is not defined

In mageckcount_trim5_auto, the value is parsed into trim_5_provided, but the very next log line referenced candidate_trim5, which is never defined in that function. The crash happens before any reads are processed, so it affects every explicit --trim-5 run. (The --trim-5 auto default takes a different branch, which is why it went unnoticed.)

Fix

Log trim_5_provided (the value that was just parsed) — a one-line change.

Test

Adds test_explicit_trim5_does_not_crash driving the explicit --trim-5 path. Verified it fails with the original NameError on the unfixed code and passes with the fix; full suite is green locally (5 passed).

Closes davidliwei/mageck2-doc#1.

mageckcount_trim5_auto logged an undefined name 'candidate_trim5' right
after parsing a numeric --trim-5, so any explicit (non-auto) --trim-5
crashed with NameError before reading any reads. Log the parsed value
'trim_5_provided' instead.

Adds a regression test driving the explicit --trim-5 path.

Fixes davidliwei/mageck2-doc#1.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@davidliwei davidliwei merged commit ff1a562 into main Jun 12, 2026
6 checks passed
@davidliwei davidliwei deleted the fix/trim5-nameerror branch June 12, 2026 20:52
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.

NameError: name 'candidate_trim5' is not defined

1 participant