Closed
Description
Bug report
Bug description:
import sys
import tempfile
def main():
tempfile.NamedTemporaryFile()
if __name__ == "__main__":
sys.exit(main())
when run with python -Werror demo.py
nothing happens
if you open a file normally you get a ResourceWarning:
import sys
import tempfile
def main():
open("example", "w")
if __name__ == "__main__":
sys.exit(main())
graingert@conscientious ~/projects/temp_file_resource_warnings python -Werror demo2.py
Exception ignored in: <_io.FileIO name='example' mode='wb' closefd=True>
Traceback (most recent call last):
File "/home/graingert/projects/temp_file_resource_warnings/demo2.py", line 6, in main
open("example", "w")
ResourceWarning: unclosed file <_io.TextIOWrapper name='example' mode='w' encoding='UTF-8'>
it appears that you do get a ResourceWarning on windows, but I've only seen it in CI I havn't reproduced locally yet
CPython versions tested on:
3.12
Operating systems tested on:
Linux