Bugs item #1341031, was opened at 2005-10-28 13:26 Message generated for change (Comment added) made by josiahcarlson You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1341031&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: liturgist (liturgist) Assigned to: Nobody/Anonymous (nobody) Summary: mmap does not accept length as 0 Initial Comment: Creating an mmap object does not accept a length parameter of zero on Linux FC4 and Cygwin. However, it does on Windows XP. $ ls -al t.dat -rw-r--r-- 1 pwatson mkgroup-l-d 64 Oct 28 10:13 t.dat $ python Python 2.4.1 (#1, May 27 2005, 18:02:40) [GCC 3.3.3 (cygwin special)] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import mmap >>> fp = open('t.dat', 'rb') >>> b = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ) Traceback (most recent call last): File "<stdin>", line 1, in ? EnvironmentError: [Errno 22] Invalid argument >>> b = mmap.mmap(fp.fileno(), 64, access=mmap.ACCESS_READ) >>> b.size() 64 ===== $ ls -al .profile -rwxrwxr-x 1 pwatson pwatson 1920 Jul 22 06:57 .profile $ python Python 2.4.1 (#1, Jul 19 2005, 14:16:43) [GCC 4.0.0 20050519 (Red Hat 4.0.0-8)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mmap >>> fp = open('.profile', 'rb') >>> b = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ) Traceback (most recent call last): File "<stdin>", line 1, in ? EnvironmentError: [Errno 22] Invalid argument >>> b = mmap.mmap(fp.fileno(), 1920, access=mmap.ACCESS_READ) >>> b.size() 1920 ---------------------------------------------------------------------- Comment By: Josiah Carlson (josiahcarlson) Date: 2005-11-07 22:17 Message: Logged In: YES user_id=341410 On Windows and Linux, I have been able to map positive, nonzero portions of files for quite some time. The only use-case I can see in using an mmap of size 0 is if the file was just created, and a user wanted to immediately resize the mmap to be larger. This can be worked-around with a simple fp.write('\0'), followed by a mmap call with size 1. Resize as desired/necessary. ---------------------------------------------------------------------- Comment By: liturgist (liturgist) Date: 2005-10-28 14:09 Message: Logged In: YES user_id=197677 It would be helpful to creating cross-platform code for all platforms to have the same requirements. If this is marked as Not-A-Bug, then how about changing it to a documentation bug so that and example could be provided? fp = open(fn, 'rb') b = mmap.mmap(fp.fileno(), os.stat(fp.name).st_size, access=mmap.ACCESS_READ) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1341031&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com