-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
ResourceWarning when open() fails with io.UnsupportedOperation: File or stream is not seekable #65509
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
Comments
>>> f = open("/dev/stdout", "w+b") # Or any non-seekable file, pipe, etc
__main__:1: ResourceWarning: unclosed file <_io.FileIO name='/dev/stdout' mode='rb+'>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
io.UnsupportedOperation: File or stream is not seekable. It is mainly just the annoyance of the ResourceWarning, so nothing major. I think this was previously identified in bpo-18116, but it looks like that bug was side-stepped by removing an equivalent fdopen() call. No ResourceWarning happens with an unbuffered file. I haven’t looked at the code but I guess the UnsupportedOperation might only be raised after trying to wrap the open FileIO object in a BufferedWriter object. |
See also bpo-20074. |
Here is a patch which fixes warnings. |
New changeset 1e30ecbfe181 by Serhiy Storchaka in branch '2.7': New changeset 17e7934905ab by Serhiy Storchaka in branch '3.4': New changeset 9c724c428e1f by Serhiy Storchaka in branch 'default': |
Thanks Victor for the review. Thanks Martin for the report. |
New changeset a98fd4eeed40 by Serhiy Storchaka in branch '3.4': New changeset 55c50c570098 by Serhiy Storchaka in branch 'default': |
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: