Always pass text to markdown()

Review Request #10699 — Created Sept. 7, 2019 and discarded — Latest diff uploaded

Information

Djblets
master

Reviewers

Previously, we were passing a binary file to markdown.markdownFromFile in
render_markdown_from_file, but this won't fly in Python 3. It expects
a file opened with an encoding. However, Django does not let you specify
an encoding when opening a file from storage, so that solution is out.
We now just read the entire file into memory, decode it from UTF-8, and
then pass that to markdown.markdown(), which returns text directly.

With this patch applied, text file attachments render correctly
in Review Board on Python 2.7, 3.5, 3.6, and 3.7.

Diff Revision 2 (Latest)

orig
1
2

Commits

First Last Summary ID Author
Always pass text to markdown()
Previously, we were passing a binary file to `markdown.markdownFromFile` in `render_markdown_from_file`, but this won't fly in Python 3. It expects a file opened with an encoding. However, Django does not let you specify an encoding when opening a file from storage, so that solution is out. We now just read the entire file into memory, decode it from UTF-8, and then pass that to `markdown.markdown()`, which returns text directly. Testing done: With this patch applied, text file attachments render correctly in Review Board on Python 2.7, 3.5, 3.6, and 3.7.
461754fc77a94d7e3573e58eb4f3c6ce828efeb4 Barret Rennie
djblets/markdown/__init__.py
Loading...