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

Skip to content

Commit 90a2427

Browse files
committed
Close file before reopening to keep Windows happy in test_sax.
1 parent 636f93c commit 90a2427

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Lib/test/test_sax.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,14 @@ def cleanup():
578578
writer.close()
579579
support.unlink(self.fname)
580580
self.addCleanup(cleanup)
581-
writer.getvalue = self.getvalue
581+
def getvalue():
582+
# Windows will not let use reopen without first closing
583+
writer.close()
584+
with open(writer.name, 'rb') as f:
585+
return f.read()
586+
writer.getvalue = getvalue
582587
return writer
583588

584-
def getvalue(self):
585-
with open(self.fname, 'rb') as f:
586-
return f.read()
587-
588589
def xml(self, doc, encoding='iso-8859-1'):
589590
return ('<?xml version="1.0" encoding="%s"?>\n%s' %
590591
(encoding, doc)).encode('ascii', 'xmlcharrefreplace')

0 commit comments

Comments
 (0)