Repository navigation
fix(reader_xlsx): add missing import subprocess (recalc silently disabled) - #38
Conversation
`_x_recalc_copy` calls `subprocess.run` twice but the module never imports `subprocess`. Because the whole body is wrapped in `except Exception: return None`, the resulting `NameError` is swallowed silently: whenever LibreOffice (`soffice`) is actually installed, the recalc path raises, returns None, and the workbook is marked "soffice unavailable" — so the formula-recalc feature never works even when it could.
There was a problem hiding this comment.
This conclusion is not correct. _reader_xlsx.py is not loaded as an independent Python module; _doc_reader.reader_src() concatenates the reader fragments into one script in a fixed order, with _reader_core.py placed before _reader_xlsx.py. _reader_core.py already executes import subprocess, so by the time _x_recalc_copy() runs, subprocess exists in the shared global namespace. The alleged NameError therefore does not occur, and the LibreOffice recalculation path is not broken for this reason.
Adding import subprocess directly to _reader_xlsx.py would be harmless and could improve the fragment’s self-containment and readability. However, it would be a defensive cleanup rather than a bug fix. Calling this a feature-breaking issue overlooks the project’s bundled execution model.
The more relevant issue is the error message: any recalculation failure is currently reported as “soffice unavailable,” which can obscure other LibreOffice execution failures.
Problem
plugins/tools/_reader_xlsx.pycallssubprocess.run(...)in_x_recalc_copy(lines 133 and 149), but the module never importssubprocess:Because the entire body of
_x_recalc_copyis wrapped intry: ... except Exception: return None, theNameError: name 'subprocess' is not definedis swallowed silently rather than crashing.Impact
_x_recalc_copyfirst checksif not shutil.which("soffice"): return None, so thesubprocess.runcalls are only reached when LibreOffice is installed. In exactly that case, the call raisesNameError, is caught, and returnsNone. The caller then does:So on any machine where
sofficeis available, the formula-recalc feature silently reports "soffice unavailable" and never recalculates empty formula caches — the feature is effectively dead.Fix
Add the missing
import subprocess. One line, no behavior change beyond letting the recalc path run as intended.🤖 Generated with Claude Code