Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aec5a56

Browse files
committed
BUG: do not remove file if passed in file object
Fix WindowsError: [Error 32] The process cannot access the file because it is being used by another process
1 parent 386a088 commit aec5a56

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/matplotlib/backends/backend_pdf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
A PDF matplotlib backend
5-
Author: Jouni K Seppänen <[email protected]>
5+
Author: Jouni K Sepp�nen <[email protected]>
66
"""
77
from __future__ import (absolute_import, division, print_function,
88
unicode_literals)
@@ -2382,7 +2382,8 @@ def close(self):
23822382
PDF file.
23832383
"""
23842384
self._file.close()
2385-
if self.get_pagecount() == 0 and self.keep_empty is False:
2385+
if (self.get_pagecount() == 0 and not self.keep_empty
2386+
and not self._file.passed_in_file_object):
23862387
os.remove(self._file.fh.name)
23872388
self._file = None
23882389

0 commit comments

Comments
 (0)