Skip to content

fix: initialize res = None to prevent UnboundLocalError (#81)#1617

Open
Jah-yee wants to merge 2 commits intomicrosoft:mainfrom
Jah-yee:fix/unbound-local-error-81
Open

fix: initialize res = None to prevent UnboundLocalError (#81)#1617
Jah-yee wants to merge 2 commits intomicrosoft:mainfrom
Jah-yee:fix/unbound-local-error-81

Conversation

@Jah-yee
Copy link

@Jah-yee Jah-yee commented Mar 13, 2026

Summary

Fixes issue #81 - UnboundLocalError: local variable 'res' referenced before assignment

When converter.accepts() returns False, the res variable is never assigned, causing an UnboundLocalError when checking if res is not None.

Fix

Initialize res = None before the conversion attempt, ensuring the variable is always defined.

Testing

This fix prevents the UnboundLocalError by ensuring res is initialized to None before the conditional block that assigns it.

penggaolai and others added 2 commits March 11, 2026 15:52
The install commands without quotes fail in some shells (e.g., zsh).
Using quoted version 'markitdown[all]' works universally.

Closes microsoft#1574
When converter.accepts() returns False, the res variable is never
assigned, causing UnboundLocalError when checking 'if res is not None'.
This fix initializes res = None before the conversion attempt.
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.

2 participants