Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: raw string from mmap.read() possible?

Reply
Thread Tools

Re: raw string from mmap.read() possible?

 
 
Dan Jones
Guest
Posts: n/a
 
      11-10-2003
On Sun, 2003-11-09 at 17:25, Fredrik Lundh wrote:
> Dan Jones wrote:
>
> > yuvframe = mmap.read(WIDTH*HEIGHT*3)
> > rgbframe = yuv.yuv2rgb(WIDTH, HEIGHT, yuvframe)
> >
> > At this point it gives a typeerror: argument 3 must be string without
> > null bytes, not str.

>
> your C extension uses the "s" marker for the third argument. don't
> do that if you plan to pass in null bytes; use "s#" instead.
>
> see the documentation for details:
>
> http://www.python.org/doc/current/api/arg-parsing.html
>
> "s" (string or Unicode object) [char *]
>
> Convert a Python string or Unicode object to a C pointer to a character
> string. /.../ The C string is NUL-terminated. The Python string must not
> contain embedded NUL bytes; if it does, a TypeError exception is raised.
> /.../
>
> "s#" (string, Unicode or any read buffer compatible object) [char *, int]
>
> This variant on "s" stores into two C variables, the first one a pointer to
> a character string, the second one its length. In this case the Python
> string may contain embedded null bytes. /.../
>
> > but if I send it a raw string it doesn't complain:
> >
> > rgbframe = yuv.yuv2rgb(WIDTH, HEIGHT, r"\0\0\0\0")
> >
> > I'm assuming this is happening because C interprets NULL as the end of
> > the string. Is there a way to get a raw string directly from the
> > mmap.read() call or do I have to do a conversion after the read?

>
> when you've fixed the C extension, I suggest reading the section
> on "raw strings" in the language reference:
>
> http://www.python.org/doc/current/ref/strings.html
>
> </F>


That worked, thanks! I was looking for a solution on the wrong end.

Dan



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RAW vs JPEGs - Does RAW show more detail? Tim Digital Photography 117 04-17-2007 03:02 PM
RAW Viewer for wide range of RAW formats greymfm Digital Photography 0 06-14-2006 09:12 PM
[Maxxum 7D] Dimage RAW Viewer v. Adobe Raw Plugin Alan Browne Digital Photography 3 03-12-2005 04:17 AM
Adobe PS RAW convertor vs Nikon RAW convertor Vlad Gunko Digital Photography 8 01-25-2005 07:43 PM
How raw is RAW format? Editor www.nutritionsoftware.org Digital Photography 4 12-22-2003 07:33 PM



Advertisments