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 ebff832

Browse filesBrowse files
committed
TST: Fix compatibility with Python 2.
1 parent fb529da commit ebff832
Copy full SHA for ebff832

File tree

1 file changed

+9
-1
lines changed
Filter options

1 file changed

+9
-1
lines changed

‎lib/matplotlib/testing/determinism.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/determinism.py
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Provides utilities to test output reproducibility.
33
"""
44

5+
import six
6+
57
import io
68
import os
79
import re
@@ -53,7 +55,13 @@ def _determinism_save(objects='mhi', format="pdf"):
5355
x = range(5)
5456
fig.add_subplot(1, 6, 6).plot(x, x)
5557

56-
fig.savefig(sys.stdout.buffer, format=format)
58+
if six.PY2 and format == 'ps':
59+
stdout = io.StringIO()
60+
else:
61+
stdout = getattr(sys.stdout, 'buffer', sys.stdout)
62+
fig.savefig(stdout, format=format)
63+
if six.PY2 and format == 'ps':
64+
sys.stdout.write(stdout.getvalue())
5765

5866
# Restores SOURCE_DATE_EPOCH
5967
if sde is None:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.