Files
codeql/python/ql/src/Resources/FileNotAlwaysClosed.py
2018-11-19 15:10:42 +00:00

16 lines
319 B
Python

f = open("filename")
... # Actions to perform on file
f.close()
# File only closed if actions are completed successfully
with open("filename") as f:
...# Actions to perform on file
# File always closed
f = open("filename")
try:
... # Actions to perform on file
finally:
f.close()
# File always closed