-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
numpy.fromfile OSError: first argument must be an open file (Python 3) #6246
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
I tried a few other The I'll try using Python 3.3 to see if the changes to |
In principle it probably could just use dup/_dup directly from C and
disregard Python.
|
I tried on a different computer with Python 3.4 to reproduce the error by constructing a Perhaps the error instead has to do with the type of file I am reading from. Its '/dev/comedi0', a data acquisition board, which has user permissions from the a udev .rules file. Previously with numpy 1.9.2 and Python 2.7, I had no issues reading from it using There are a few error cases in |
After commenting out the error string setting in multiarraymodule.c#L2121, I was given the correct error message from npy_3kcompat.h#L250. This issue is an unintended bug that cropped up after the fix for issue #4118. Since my file can not preform First off, the line in multiarraymodule.c#L2121 should be removed, because it defeats the purpose of having the specific error messages in npy_3kcompat.h -- PR to follow. Secondly, I don't think the |
The problem here is in synchronizing the Python3 file handle position and its potential buffering with the OS-level handle. For files that don't have random access, it's not very clear how to do this. |
The file is opened as an unbuffered I/O using the open(filename, "rb+", buffering=0) Since there should be no buffering, can this situation be handled? |
I don't know. This depends on implementation details of CPython, and would have to be checked. |
I have a related issue using older versions. |
I don't know. @rpratt20 does your problem persist with current numpy? If so, could you open an new issue and paste in a code snippet that illustrates the problem. |
Someone pointed out to me that fromfile is designed to read straight from a file and not buffered. Using this: Randy Is this closable now that #6330 has landed, or should it stay open until @rpratt20's Python 2 issue has been addressed? — |
Thanks @charris! |
Using Python 3 and Numpy 1.9.2 there is an issue with
numpy.fromfile
when called on an existing file object. This code works fine in Python 2.7.I've checked
fh.closed
isFalse
, so the file is still open. The error is thrown by numpy.multiarraymodule.c#2119.Someone mentioned these issues on Stack Overflow, but no clear solutions are present.
Any suggestions?
The text was updated successfully, but these errors were encountered: