Skip to content

Commit

Permalink
Merge pull request sympy#19904 from eric-wieser/fix-preview
Browse files Browse the repository at this point in the history
printing.preview: Fix regressions introduced in sympygh-18392
  • Loading branch information
oscarbenjamin authored Aug 7, 2020
2 parents 2c5e319 + 885e45a commit c3087c8
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions sympy/printing/preview.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import print_function, division

import io
from io import BytesIO
import os
from os.path import join
import shutil
Expand Down Expand Up @@ -136,11 +135,9 @@ def preview(expr, output='png', viewer=None, euler=True, packages=(),
except KeyError:
raise SystemError("Invalid output format: %s" % output)
else:
if viewer == "StringIO":
viewer = "BytesIO"
if outputbuffer is None:
raise ValueError("outputbuffer has to be a BytesIO "
"compatible object if viewer=\"StringIO\"")
if viewer == "file":
if filename is None:
raise ValueError("filename has to be specified if viewer=\"file\"")
elif viewer == "BytesIO":
if outputbuffer is None:
raise ValueError("outputbuffer has to be a BytesIO "
Expand Down Expand Up @@ -250,13 +247,7 @@ def preview(expr, output='png', viewer=None, euler=True, packages=(),
src = "texput.%s" % (output)

if viewer == "file":
if filename is None:
buffer = BytesIO()
with open(join(workdir, src), 'rb') as fh:
buffer.write(fh.read())
return buffer
else:
shutil.move(join(workdir,src), filename)
shutil.move(join(workdir, src), filename)
elif viewer == "BytesIO":
with open(join(workdir, src), 'rb') as fh:
outputbuffer.write(fh.read())
Expand Down

0 comments on commit c3087c8

Please sign in to comment.