8000 Merge pull request #20478 from meeseeksmachine/auto-backport-of-pr-20… · matplotlib/matplotlib@0580c0d · GitHub
[go: up one dir, main page]

Skip to content

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 0580c0d

Browse files
authored
Merge pull request #20478 from meeseeksmachine/auto-backport-of-pr-20473-on-v3.4.x
Backport PR #20473 on branch v3.4.x (_GSConverter: handle stray 'GS' in output gracefully)
2 parents 09dcdf2 + fd55320 commit 0580c0d

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