Skip to content

Commit 7766ca2

Browse files
committed
tempfile.mkstemp handles must be explicitly closed on Windows before the associated file can be closed
1 parent ac27fcb commit 7766ca2

2 files changed

+4
-2
lines changed

examples/test/test_i_basic_file_encryption_with_multiple_providers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
def test_cycle_file():
3232
cmk_arn = get_cmk_arn()
33-
_handle, filename = tempfile.mkstemp()
33+
handle, filename = tempfile.mkstemp()
3434
with open(filename, 'wb') as f:
3535
f.write(os.urandom(1024))
3636
try:
@@ -42,4 +42,5 @@ def test_cycle_file():
4242
for f in new_files:
4343
os.remove(f)
4444
finally:
45+
os.close(handle)
4546
os.remove(filename)

examples/test/test_i_basic_file_encryption_with_raw_key_provider.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727

2828

2929
def test_cycle_file():
30-
_handle, filename = tempfile.mkstemp()
30+
handle, filename = tempfile.mkstemp()
3131
with open(filename, 'wb') as f:
3232
f.write(os.urandom(1024))
3333
try:
3434
new_files = cycle_file(source_plaintext_filename=filename)
3535
for f in new_files:
3636
os.remove(f)
3737
finally:
38+
os.close(handle)
3839
os.remove(filename)

0 commit comments

Comments
 (0)