Fix render_markdown_from_file() on Python 3.
Review Request #11766 — Created Aug. 1, 2021 and submitted
render_markdown_from_file()was using a
cStringIOas the file
output, which wasn't compatible with the results from
markdownFromFile()on Python 3. This wasn't caught due to the lack of
unit tests for this function.
Now, the stream is written to a
io.BytesIO. Missing documentation was
added that specifies that the input stream must be a byte stream.
Along with this, the code has been made safer from leaks by closing the
outgoing stream in a
finally:clause. While this shouldn't technically
be necessary (garbage collection should handle closing this for us), it
is slightly more correct.
A unit test was added to ensure this works on Python 2 and 3.
Unit tests pass on Python 2 and 3.
Without the fix, the test fails on Python 3 .