8000 Backport PR #20473 on branch v3.4.x (_GSConverter: handle stray 'GS' in output gracefully) by meeseeksmachine · Pull Request #20478 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport PR #20473 on branch v3.4.x (_GSConverter: handle stray 'GS' in output gracefully) #20478

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/matplotlib/testing/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _read_until(self, terminator):
raise _ConverterError
buf.extend(c)
if buf.endswith(terminator):
return bytes(buf[:-len(terminator)])
return bytes(buf)


class _GSConverter(_Converter):
Expand Down Expand Up @@ -154,15 +154,16 @@ def encode_and_escape(name):
+ b") run flush\n")
self._proc.stdin.flush()
# GS> if nothing left on the stack; GS<n> if n items left on the stack.
err = self._read_until(b"GS")
stack = self._read_until(b">")
err = self._read_until((b"GS<", b"GS>"))
stack = ""
if err.endswith(b"GS<"):
stack = self._read_until(b">")
if stack or not os.path.exists(dest):
stack_size = int(stack[1:]) if stack else 0
stack_size = int(stack[:-1]) if stack else 0
self._proc.stdin.write(b"pop\n" * stack_size)
# Using the systemencoding should at least get the filenames right.
raise ImageComparisonFailure(
(err + b"GS" + stack + b">")
.decode(sys.getfilesystemencoding(), "replace"))
(err + stack).decode(sys.getfilesystemencoding(), "replace"))


class _SVGConverter(_Converter):
Expand Down
0