[issue15676] mmap: add empty file check prior to offset check
Charles-François Natali added the comment: You forgot to add an entry in Misc/ACKS. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Roundup Robot added the comment: New changeset 9ed2e8307e60 by Jesus Cea in branch '2.7': #15676: Proper attribution in Misc/ACKS http://hg.python.org/cpython/rev/9ed2e8307e60 New changeset 4f21f7532038 by Jesus Cea in branch '3.2': #15676: Proper attribution in Misc/ACKS http://hg.python.org/cpython/rev/4f21f7532038 New changeset 4fdc6c501e63 by Jesus Cea in branch 'default': MERGE: #15676: Proper attribution in Misc/ACKS http://hg.python.org/cpython/rev/4fdc6c501e63 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Stefan Krah added the comment: For some reason all Windows buildbots are failing since f962ec8e47a1: == ERROR: test_entire_file (test.test_mmap.MmapTests) -- Traceback (most recent call last): File D:\Buildslave\3.x.moore-windows\build\lib\test\test_mmap.py, line 19, in setUp os.unlink(TESTFN) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '@test_2636_tmp' == ERROR: test_error (test.test_mmap.MmapTests) -- Traceback (most recent call last): File D:\Buildslave\3.x.moore-windows\build\lib\test\test_mmap.py, line 19, in setUp os.unlink(TESTFN) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '@test_2636_tmp' == [...] -- nosy: +skrah resolution: fixed - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Stefan Krah added the comment: This gets rid of the permission error: diff -r f962ec8e47a1 Lib/test/test_mmap.py --- a/Lib/test/test_mmap.py Mon Sep 10 01:23:05 2012 +0200 +++ b/Lib/test/test_mmap.py Mon Sep 10 22:22:38 2012 +0200 @@ -491,11 +491,11 @@ def test_empty_file (self): f = open (TESTFN, 'w+b') f.close() -f = open(TESTFN, rb) -self.assertRaisesRegex(ValueError, - cannot mmap an empty file, - mmap.mmap, f.fileno(), 0, access=mmap.ACCESS_READ) -f.close() +with open(TESTFN, rb) as f: +self.assertRaisesRegex(ValueError, + cannot mmap an empty file, + mmap.mmap, f.fileno(), 0, + access=mmap.ACCESS_READ) def test_offset (self): f = open (TESTFN, 'w+b') But the test still fails: == CPython 3.3.0rc2+ (default, Sep 10 2012, 22:01:26) [MSC v.1600 64 bit (AMD64)] == Windows-7-6.1.7601-SP1 little-endian == C:\Users\stefan\pydev\cpython\build\test_python_2908 Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_use r_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1) [1/1] test_mmap test_empty_file (test.test_mmap.MmapTests) ... FAIL == FAIL: test_empty_file (test.test_mmap.MmapTests) -- ValueError: mmap offset is greater than file size During handling of the above exception, another exception occurred: Traceback (most recent call last): File C:\Users\stefan\pydev\cpython\lib\test\test_mmap.py, line 498, in test_empty_file access=mmap.ACCESS_READ) AssertionError: cannot mmap an empty file does not match mmap offset is greater than file size -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Roundup Robot added the comment: New changeset 25d477647a2d by Jesus Cea in branch '2.7': #15676: mmap: add empty file check prior to offset check - Previous patch was incomplete http://hg.python.org/cpython/rev/25d477647a2d -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Roundup Robot added the comment: New changeset 88a88c32661e by Jesus Cea in branch '3.2': #15676: mmap: add empty file check prior to offset check - Previous patch was incomplete http://hg.python.org/cpython/rev/88a88c32661e New changeset 0ac94ae29abe by Jesus Cea in branch 'default': #15676: mmap: add empty file check prior to offset check - Previous patch was incomplete http://hg.python.org/cpython/rev/0ac94ae29abe -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Stefan Krah added the comment: I think Py_DECREF(m_obj) is missing (at least in 3.3, I didn't look at the other versions). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Roundup Robot added the comment: New changeset 39efccf7a167 by Jesus Cea in branch '2.7': #15676: mmap: add empty file check prior to offset check - Previous patch was incomplete (fix 2) http://hg.python.org/cpython/rev/39efccf7a167 New changeset 56a2e862561c by Jesus Cea in branch '3.2': #15676: mmap: add empty file check prior to offset check - Previous patch was incomplete (fix 2) http://hg.python.org/cpython/rev/56a2e862561c New changeset 306b2ecb1a3e by Jesus Cea in branch 'default': MERGE: #15676: mmap: add empty file check prior to offset check - Previous patch was incomplete (fix 2) http://hg.python.org/cpython/rev/306b2ecb1a3e -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Jesús Cea Avión added the comment: Thanks for the heads-up, Stefan. -- assignee: - jcea resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Steven Willis added the comment: Here's a patch for 3.1 -- Added file: http://bugs.python.org/file27153/issue15676-3.1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Steven Willis added the comment: Here's a patch for 3.2 -- Added file: http://bugs.python.org/file27154/issue15676-3.2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Steven Willis added the comment: Here's a branch against the default branch in mercurial. I couldn't find a branch for 3.3 or 3.4. -- Added file: http://bugs.python.org/file27155/issue15676-default.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Changes by Steven Willis onlyn...@gmail.com: -- versions: +Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Charles-François Natali added the comment: Thanks for the patches. Note that you don't have to provide a patch for each branch, it's usually the committer's job. The patch looks good, but the test could be rewritten with assertRaisesRegex(): http://docs.python.org/dev/library/unittest.html#unittest.TestCase.assertRaisesRegex -- nosy: +neologix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Steven Willis added the comment: Sorry, I thought that's what jcea was asking for. Here's an updated patch for the default branch in mercurial that uses assertRaisesRegex in the test. -- Added file: http://bugs.python.org/file27156/issue15676-default.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Jesús Cea Avión added the comment: Having separate patches is useful if the patch can not be applied cleanly to different python branches. This is specially true with 2.7/3.x. Checking the fix and committing it to 2.7, 3.2 and 3.3 (probably available in 3.3.1, not 3.3.0, already in release candidate). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Roundup Robot added the comment: New changeset d85f80b31b54 by Jesus Cea in branch '3.2': Closes #15676: mmap: add empty file check prior to offset check http://hg.python.org/cpython/rev/d85f80b31b54 New changeset f962ec8e47a1 by Jesus Cea in branch 'default': Closes #15676: mmap: add empty file check prior to offset check http://hg.python.org/cpython/rev/f962ec8e47a1 New changeset 27837a33790d by Jesus Cea in branch '2.7': Closes #15676: mmap: add empty file check prior to offset check http://hg.python.org/cpython/rev/27837a33790d -- nosy: +python-dev resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Steven Willis added the comment: Here's a patch for 2.7. I don't know if it cleanly applies to the rest. -- keywords: +patch Added file: http://bugs.python.org/file27140/issue15676.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Changes by Berker Peksag berker.pek...@gmail.com: -- versions: -Python 3.1, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
New submission from Steven Willis: There are a number of issues dealing with the offset and length checks in offset, such as issue12556. I'm running into this issue as well, but with a normal file that happens to be empty. I'm trying to access it with: mmap.mmap(f.fileno(), length=0, access=mmap.ACCESS_READ) So the length and offset should be calculated automatically. The man page for mmap says: SUSv3 specifies that mmap() should fail if length is 0. However, in kernels before 2.6.12, mmap() succeeded in this case: no mapping was created and the call returned addr. Since kernel 2.6.12, mmap() fails with the error EINVAL for this case. So alright, mmapping an empty file is now allowed. But, could the check for an empty file be done prior to the check for the offset exceeding the size of the file? It would be much clearer in the cases where an empty (regular or otherwise) file was mmapped if the error message were something like empty files cannot be mapped insted of offset is greater than file size since I didn't even set the offset. -- components: Library (Lib) messages: 168314 nosy: Steven.Willis priority: normal severity: normal status: open title: mmap: add empty file check prior to offset check type: behavior versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Jesús Cea Avión added the comment: I do agree. Solaris also returns an error if len=0. Could you please, provide patches for 2.7, 3.2 and 3.3? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com