[Patches] [ python-Patches-708374 ] add offset to mmap

SourceForge.net noreply@sourceforge.net
Thu, 10 Apr 2003 10:53:34 -0700


Patches item #708374, was opened at 2003-03-23 09:33
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=708374&group_id=5470

Category: Modules
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
Assigned to: Raymond Hettinger (rhettinger)
Summary: add offset to mmap

Initial Comment:
This patch is from Yotam Medini <yotamm at
mellanox.co.il> sent to me in mail.

It adds support for the offset parameter to mmap.

It ignores the check for mmap size "if the file is
character device.  Some device drivers (which I happen
to use) have zero size in fstat buffer, but still one
can seek() read() and tell()."
I added minimal doc and tests.

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-04-10 12:53

Message:
Logged In: YES 
user_id=80475

I had posted the wrong traceback (before the rebuild).  
The correct one shows Window Error #87.

Traceback (most recent call last):
  File "test_mmap.py", line 357, in ?
    test_main()
  File "test_mmap.py", line 353, in test_main
    test_offset()
  File "test_mmap.py", line 37, in test_offset
    m = mmap.mmap(f.fileno(), mapsize - PAGESIZE, 
offset=PAGESIZE)
WindowsError: [Errno 87] The parameter is incorrect
[9363 refs]


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-04-10 12:14

Message:
Logged In: YES 
user_id=33168

Note to self:  Self, make sure to backport S_ISCHR() fix.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-04-10 12:10

Message:
Logged In: YES 
user_id=33168

Hmmm, did Modules/mmapmodule.c get rebuilt?  There is code
in the patch for new_mmap_object() to support the offset
keyword in both Unix & Windows.  I don't see a problem in
the code/patch.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-04-10 11:01

Message:
Logged In: YES 
user_id=80475

It doesn't run:

C:\py23\Lib\test>python_d test_mmap.py
Traceback (most recent call last):
  File "test_mmap.py", line 357, in ?
    test_main()
  File "test_mmap.py", line 353, in test_main
    test_offset()
  File "test_mmap.py", line 37, in test_offset
    m = mmap.mmap(f.fileno(), mapsize - PAGESIZE, 
offset=PAGESIZE)
TypeError: 'offset' is an invalid keyword argument for this 
function
[9363 refs]


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-04-09 18:35

Message:
Logged In: YES 
user_id=33168

Raymond, could you try to test this patch and see if it
works on Windows?

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-29 16:28

Message:
Logged In: YES 
user_id=33168

Sounds fair.  Attached is an updated patch which includes
windows support (I think).  I cannot test on Windows. 
Tested on Linux.  Includes updates for doc, src, and test.

----------------------------------------------------------------------

Comment By: Martin v. L÷wis (loewis)
Date: 2003-03-27 19:12

Message:
Logged In: YES 
user_id=21627

I think non-zero offsets need to be supported for Windows as
well.


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-23 10:37

Message:
Logged In: YES 
user_id=33168

Email received from Yotam:

I have downloaded and patched the 2.3a source. compiled
locally just this module, and it worked fine for my
application (with offset for character device file) I did
not run the released test though.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=708374&group_id=5470