sphinx-pretty-searchresults
sphinx-pretty-searchresults copied to clipboard
UnboundLocalError
Version 0.3.5
Exception occurred:
File "/home/tim/miniconda3/envs/mpl/lib/python3.6/site-packages/sphinxprettysearchresults/__init__.py", line 61, in clean_txts
os.rename(os.path.join(root, file), os.path.join(root, file.replace('.txt', source_suffix + '.txt')))
UnboundLocalError: local variable 'source_suffix' referenced before assignment
There's some logic error here. source_suffix is not set if not file.endswith('.txt'). Not sure if there has to be an alternate default or if the rename shouldn't take place in that case.
Also the file.replace('.txt') are a bit dangerous in case that substring is present somewhere within the filename.
Thanks for reporting. I'll take a look as soon as I find time.
@timhoffm could you provide a minimal failing example? ATM, I can fix the specific issues in the code but feel a bit uncomfortable because I don't have a failing test.
Unfortunately, I don't have a minimal example. It occurred when trying to build the matplotlib docs with sphinx-pretty-searchresults. The provided exception message was all information available. I have no idea what part of the docs was responsible for the error or how to obtain that information.
Additional to the above error, there was a problem with a proprietary sphinx directive. After fixing that, the above error was gone as well.
Ok. The setup of the matplotlib docs is not really straight-forward, so it might take me some time to isolate the issue. But you could install from this branch: https://github.com/TimKam/sphinx-pretty-searchresults/tree/27-fix-unboundlocalerror. Does this fix your issue?