Crash when specifying extra_args incorrectly
alhirzel opened this issue · 2 comments
I noticed an issue when using pypandoc
for the first time. I was able to work through it, but I want to report it as an issue because the behavior was surprising. MNWE:
from pypandoc import convert_text
print(convert_text("<b>Test</b>", "md", format="html", extra_args="--ascii"))
This gives the following result:
Traceback (most recent call last):
File "/home/alhirzel/prj/20221023_mnwe_pypandoc_crash/crash.py", line 3, in <module>
print(convert_text("<b>Hello</b>", "md", format="html", extra_args="--ascii"))
File "/usr/lib/python3.10/site-packages/pypandoc/__init__.py", line 93, in convert_text
return _convert_input(source, format, 'string', to, extra_args=extra_args,
File "/usr/lib/python3.10/site-packages/pypandoc/__init__.py", line 418, in _convert_input
raise RuntimeError(
RuntimeError: Pandoc died with exitcode "1" during conversion: pandoc: <stdin>: hGetBuf: illegal operation (handle is closed)
I was able to identify a fix for this issue after reviewing the README more carefully (namely, the extra_args
argument must be an array of strings).
Versions: pandoc 2.19.2, pypandoc 1.9-2, on Arch Linux
yes. We could probably raise a ValueError, but if we start doing this, we would need to do this for every argument.
I would say that we already have enough in place to prevent this, namely both the documentation, and type hints which will show up in an IDE.
But I'm open to hearing what other people think of this.