regular expressions with other string classes

Nicholas FitzRoy-Dale wzdd at lardcave.net
Wed Sep 19 09:43:22 EDT 2001


On 19 Sep, Andrew Dalke wrote:

> Nicholas FitzRoy-Dale wrote

>> mboxMap = mmap.mmap (handle.fileno(), getFileLength (self.sourceFilename),
>>   mmap.MAP_SHARED, mmap.PROT_READ)
> 
> Well, there's my problem.  I've nearly no clue on how to use
> the mmap module, so I assumed I could use the defaults.

Ah, right. 

> Just tried out what you did, and it works.
> 
> The following doesn't work:

<snip>

> In this case, the mmap call is missing the MAP_SHARED flag
> (which is the default, so should be fine).  It's also missing
> the PROT_READ flag, so the default of PROT_READ | PROT_WRITE
> is used.
> 
> I guess that's the problem, but you can see why the error message
> threw me off.

Actually, I just did a bit of testing, and it seems that it's the file
length param that's causing that error - supplying 0 doesn't work. I
initially supplied a very large file length and predictably got sigsegv
or something when the re ran off the end of the file :-) so I actually
supplied the correct length and it worked.

I agree that "expected string or buffer" doesn't come close to
indicating "you've got a zero-length mmap, fix!" though. :)

-- 
- Nicholas FitzRoy-Dale
http://www.lardcave.net

 /. signature:
"Hit a man on the head with a fish, and he'll have a headache for a day..."





More information about the Python-list mailing list