Skip to content
Prev Previous commit
Update Lib/test/test_msvcrt.py
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
  • Loading branch information
aisk and zooba authored Sep 8, 2023
commit dff3acce48b7a7e1d66921fdc7da0f99686ef075
9 changes: 7 additions & 2 deletions Lib/test/test_msvcrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ def test_open_osfhandle(self):
h = _winapi.CreateFile(TESTFN_ASCII, _winapi.GENERIC_WRITE, 0, 0, 1, 128, 0)
self.addCleanup(os_helper.unlink, TESTFN_ASCII)

fd = msvcrt.open_osfhandle(h, os.O_RDONLY)
os.close(fd)
try:
fd = msvcrt.open_osfhandle(h, os.O_RDONLY)
h = None
os.close(fd)
finally:
if h:
_winapi.CloseHandle(h)

def test_get_osfhandle(self):
with open(TESTFN, "w") as f:
Expand Down