Issue964876
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2004-06-02 09:28 by manlioperillo, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (8) | |||
---|---|---|---|
msg20983 - (view) | Author: Manlio Perillo (manlioperillo) | Date: 2004-06-02 09:28 | |
>>> sys.version '2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)]' >>> sys.platform 'win32' >>> sys.getwindowsversion() (5, 1, 2600, 2, '') Hi. If I mmap a 0 length file on winnt, I obtain an exception: >>> import mmap, os >>> file = os.open(file_name, os.O_RDWR | os.O_BINARY) >>> buf = mmap.mmap(file, 0, access = map.ACCESS_WRITE) Traceback (most recent call last): File "<pyshell#15>", line 1, in -toplevel- buf = mmap.mmap(file, 0, access = mmap.ACCESS_WRITE) WindowsError: [Errno 1006] Il volume corrispondente al file è stato alterato dall'esterno. Il file aperto non è più valido This is a windows problem, but I think it should be at least documented. Thanks and regards Manlio Perillo |
|||
msg20984 - (view) | Author: Paul Moore (paul.moore) * | Date: 2004-06-05 18:01 | |
Logged In: YES user_id=113328 Suggested documentation patch: Index: lib/libmmap.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmmap.tex,v retrieving revision 1.8 diff -u -r1.8 libmmap.tex --- lib/libmmap.tex 3 Dec 2001 18:27:22 -0000 1.8 +++ lib/libmmap.tex 5 Jun 2004 18:00:08 -0000 @@ -44,7 +44,9 @@ specified by the file handle \var{fileno}, and returns a mmap object. If \var{length} is \code{0}, the maximum length of the map will be the current size of the file when \function{mmap()} is - called. + called. If \var{length} is \code{0} and the file is 0 bytes long, + Windows will return an error. It is not possible to map a 0-byte + file under Windows. \var{tagname}, if specified and not \code{None}, is a string giving a tag name for the mapping. Windows allows you to have many |
|||
msg20985 - (view) | Author: Tim Peters (tim.peters) * | Date: 2004-06-05 21:46 | |
Logged In: YES user_id=31435 The patch looks good. On American Windows, the cryptic error msg is: "WindowsError: [Errno 1006] The volume for a file has been externally altered so that the opened file is no longer valid" Can't find any MS docs on this condition. Then again, mapping an empty file *as* a size-0 file isn't a sane thing to do anyway. |
|||
msg20986 - (view) | Author: Manlio Perillo (manlioperillo) | Date: 2004-06-06 11:15 | |
Logged In: YES user_id=1054957 tim_one wrote that mapping an empty file as a size-0 file isn't a sane thing to do anyway. I think this is not really true. mmap has a resize method, so, in theory, one can map a size-0 file and let it grow. |
|||
msg20987 - (view) | Author: Tim Peters (tim.peters) * | Date: 2004-06-06 16:14 | |
Logged In: YES user_id=31435 No, on Windows it's not sane. While the Python mmap module has a .resize() method, Microsoft's file mapping API does not -- .resize() on Windows is accomplished by throwing away the current mapping and creating a brand new one. On non-Windows systems, it's not guaranteed that Python can do a .resize() at all (it depends on whether the platform C supports mremap() -- if it doesn't, you get a SystemError mmap: resizing not available--no mremap() exception). So "in theory" ignores too much of reality to take seriously. |
|||
msg20988 - (view) | Author: Tim Peters (tim.peters) * | Date: 2004-06-06 16:56 | |
Logged In: YES user_id=31435 Clarified the docs, on HEAD and 2.3 maint: Doc/lib/libmmap.tex new revisions 1.8.24.1 and 1.9. |
|||
msg20989 - (view) | Author: Paul Moore (paul.moore) * | Date: 2004-06-07 09:18 | |
Logged In: YES user_id=113328 FWIW, the documentation for CreateFileMapping (available at http://msdn.microsoft.com/library/en- us/fileio/base/createfilemapping.asp) states under the documentation for the dwMaximumSizeLow parameter that mapping a file of size 0 is invalid. |
|||
msg20990 - (view) | Author: Tim Peters (tim.peters) * | Date: 2004-06-07 14:54 | |
Logged In: YES user_id=31435 So it does! I was looking at old docs. Thanks. At the C level, someone must have used the generic-sounding ERROR_FILE_INVALID without realizing how strange the associated text is in this context. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:04 | admin | set | github: 40328 |
2004-06-02 09:28:09 | manlioperillo | create |