Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when specifying extra_args incorrectly #306

Open
alhirzel opened this issue Oct 23, 2022 · 2 comments
Open

Crash when specifying extra_args incorrectly #306

alhirzel opened this issue Oct 23, 2022 · 2 comments
Labels
waiting Waiting for User Input
Milestone

Comments

@alhirzel
Copy link

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

@JessicaTegner
Copy link
Owner

This was also reported in #197 and a pr was made in #199 but weren't for some reason merged. I'll see to it being fixed asap :)

@JessicaTegner
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting for User Input
Projects
None yet
Development

No branches or pull requests

2 participants