New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Got ResourceWarning unclosed file when running Lib/shlex.py demo #63053
Comments
The python is compiled with --with-pydebug flag. [sky@localhost cpython]$ cat /tmp/quote.txt Attached the patch to close the file when running the demo. |
I think the warning should be silenced on all versions where it occurs. There is no real problem here, but there can be with multiple opens without close on non-refcounted interpreters. Patch looks good but I have not tried it. |
The patch LGTM as well. ResourceWarning was silenced after applying patch when tested on my machine. |
It seems commit ready. |
New changeset 4c2b77d0680b by R David Murray in branch '3.4': New changeset 8ed630f28753 by R David Murray in branch 'default': |
Thanks for the patch, Vajrasky, but I chose a different fix, since the proposed one could leave the file open if the shlex constructor raised an error. Not particularly important, but as long as we are cleaning up the code we might as well make it as clean as we can. Since 2.7 doesn't generate ResourceWarnings I chose not to apply it there. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: