-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
Description
I have been looking through the low level functions of astropy for GsoC 2026.
Looking at the FileString class in io/ascii/cparser.pyx
def __cinit__(self, fname):
self.fhandle = open(fname, 'r')
if not self.fhandle:
raise OSError('File "{0}" could not be opened'.format(fname))
self.mmap = mmap.mmap(self.fhandle.fileno(), 0, access=mmap.ACCESS_READ)
cdef Py_ssize_t buf_len = len(self.mmap)
PyObject_GetBuffer(self.mmap, &self.buf, PyBUF_SIMPLE)
self.mmap_ptr = self.buf.buf I was thinking wouldnt the check if not self.fhanlde be redundant because if the open failed it would immediately raise the error and if it was successful that code would be skipped, if so that error would never be raised.
Expected behavior
No response
How to Reproduce
Versions
No response
Reactions are currently unavailable