8000 Backport PR #20473: _GSConverter: handle stray 'GS' in output gracefully · matplotlib/matplotlib@fd55320 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fd55320

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #20473: _GSConverter: handle stray 'GS' in output gracefully
1 parent 09dcdf2 commit fd55320

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/matplotlib/testing/compare.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _read_until(self, terminator):
124124
raise _ConverterError
125125
buf.extend(c)
126126
if buf.endswith(terminator):
127-
return bytes(buf[:-len(terminator)])
127+
return bytes(buf)
128128

129129

130130
class _GSConverter(_Converter):
@@ -154,15 +154,16 @@ def encode_and_escape(name):
154154
+ b") run flush\n")
155155
self._proc.stdin.flush()
156156
# GS> if nothing left on the stack; GS<n> if n items left on the stack.
157-
err = self._read_until(b"GS")
158-
stack = self._read_until(b">")
157+
err = self._read_until((b"GS<", b"GS>"))
158+
stack = ""
159+
if err.endswith(b"GS<"):
160+
stack = self._read_until(b">")
159161
if stack or not os.path.exists(dest):
160-
stack_size = int(stack[1:]) if stack else 0
162+
stack_size = int(stack[:-1]) if stack else 0
161163
self._proc.stdin.write(b"pop\n" * stack_size)
162164
# Using the systemencoding should at least get the filenames right.
163165
raise ImageComparisonFailure(
164-
(err + b"GS" + stack + b">")
165-
.decode(sys.getfilesystemencoding(), "replace"))
166+
(err + stack).decode(sys.getfilesystemencoding(), "replace"))
166167

167168

168169
class _SVGConverter(_Converter):

0 commit comments

Comments
 (0)
0