Skip to content

Commit 6e451f1

Browse files
tacaswellkahnchana
authored andcommitted
MNT: explicitly pass in file handle to print_figure_impl
Rather than closing over it and relying on it being defined in the top-level function namespace.
1 parent 465a453 commit 6e451f1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ def write(self, *kl, **kwargs):
10691069
creator_str = "matplotlib version " + __version__ + \
10701070
", http://matplotlib.org/"
10711071

1072-
def print_figure_impl():
1072+
def print_figure_impl(fh):
10731073
# write the PostScript headers
10741074
if isEPSF:
10751075
print("%!PS-Adobe-3.0 EPSF-3.0", file=fh)
@@ -1169,7 +1169,7 @@ def print_figure_impl():
11691169
# Write to a temporary file.
11701170
fd, tmpfile = mkstemp()
11711171
with io.open(fd, 'w', encoding='latin-1') as fh:
1172-
print_figure_impl()
1172+
print_figure_impl(fh)
11731173
else:
11741174
# Write directly to outfile.
11751175
if passed_in_file_object:
@@ -1187,10 +1187,10 @@ def do_nothing():
11871187
else:
11881188
fh = outfile
11891189

1190-
print_figure_impl()
1190+
print_figure_impl(fh)
11911191
else:
11921192
with io.open(outfile, 'w', encoding='latin-1') as fh:
1193-
print_figure_impl()
1193+
print_figure_impl(fh)
11941194

11951195
if rcParams['ps.usedistiller']:
11961196
if rcParams['ps.usedistiller'] == 'ghostscript':

0 commit comments

Comments
 (0)