Skip to content

Commit

Permalink
printing.preview: Fix regressions introduced in sympygh-18392
Browse files Browse the repository at this point in the history
These were:

* `viewer="StringIO"` being undeprecated again
* `viewer="file"` becoming broken

Co-authored-by: Sebastian Müller <mueller.seb@posteo.de>
  • Loading branch information
eric-wieser and MuellerSeb committed Aug 7, 2020
1 parent b92b971 commit 885e45a
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 885e45a

Please sign in to comment.