Skip to content

fix: initialize res to None to prevent UnboundLocalError#1621

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

fix: initialize res to None to prevent UnboundLocalError#1621
Jah-yee wants to merge 2 commits intomicrosoft:mainfrom
Jah-yee:fix/unbound-local-error-res

Conversation

@Jah-yee
Copy link
Copy Markdown

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

Fixes issue #81 - UnboundLocalError when no converter accepts the file.

The variable res was only set inside the if _accepts: block, but was checked later outside of it. When no converter accepts the file, res would be undefined, causing UnboundLocalError.

This is a one-line fix that initializes res = None before the converter loop.

OpenClaw AI and others added 2 commits March 11, 2026 23:40
- Add helper function _format_cell_value() to preserve currency symbols
- Support for USD ($), EUR (€), GBP (£), JPY (¥), and other currencies
- Support for percentage formatting
- Preserve decimal places from number format
- Use openpyxl directly instead of pandas for better format control

Fixes microsoft#53
Fixes issue microsoft#81 - UnboundLocalError when no converter accepts the file.

The variable res was only set inside the 'if _accepts:' block, but was
checked later outside of it. When no converter accepts the file,
res would be undefined, causing UnboundLocalError.
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