Hi there,
The odf_odt Writer currently prints an error message on Windows that cannot be captured with the usual stdout/stderr capture techniques, since it originates in a popen.
To reproduce, it's enough to call "rst2odt.py some_valid_source.rst whatever.odt"
I found the bug on Python 3.6.5 and Docutils 0.14, but the faulty popen call is present in latest docutils
The output odt file is created as expected, but we see "The system cannot find the path specified" printed in the terminal. Worse, any application code using odf_odt Writer will print this error message. The message is not capturable AFAIK with the usual stdout/stderr techniques (contextlib.redirect_stdout or similar) since it originates in a popen call.
The faulty popen call is in http://svn.code.sf.net/p/docutils/code/trunk/docutils/docutils/writers/odf_odt/init.py
class ODFTranslator, method setup_paper:
fin = os.popen("paperconf -s 2> /dev/null")
On Windows, the "/dev/null" path does not exist (except specific cases such as the Windows 10 WSL Linux subsystem. The shell thus prints the error.
I propose this patch which seems compatible with both Python > 2.4 and 3:
fin = subprocess.check_output("paperconf -s", stderr=subprocess.DEVNULL)
This is tested and works on windows with python 3. It should work fine on Linux and MacOS.
Thank you for the report and patch proposal.
An updated variant of your proposal is applied in [r8888] and should fix the issue.
Related
Commit: [r8888]
Last edit: Günter Milde 2022-07-06
Fixed in Docutils 0.19.
Thank you for the report.