Hi,

I think the problem is that Python 3 now distinguishes between strings
(unicode) and binary strings (not unicode?). Try using

img_string = b"\77\77\77\33\177\177\177\44\277\277\277\55\377\0\0\66" + \
              b"\0\377\0\77\0\01\37\0"

Note the extra "b" before the leading quotes. This problem comes up in
quite a few places with Python 3 that I've been encountering recently, not
just with PyX.

I've not tested this but hopefully it works!

Cheers
David
--
David Barton
On 30 Mar 2015 22:21, "Arnd Baecker" <[email protected]> wrote:

> Hi,
>
> in the process of preparing our transition to python 3
> I encountered a problem with bitmap, which could
> be boiled down to:
>
> #------------------------------
> from pyx import *
> img_string = "\77\77\77\33\177\177\177\44\277\277\277\55\377\0\0\66" + \
>               "\0\377\0\77\0\01\37\0"
> image_rgb = bitmap.image(3, 2, "RGBA", img_string)
> bitmap_rgb = bitmap.bitmap(0, 0, image_rgb, height=0.8)
> c = canvas.canvas()
> c.insert(bitmap_rgb)
> c.writePDFfile("minimal")
> #------------------
>
> This code runs fine under python 2.7 (and pyx 0.12.1)
> while under python 3.4 (and pyx 0.13) I get:
>    lib/python3.4/site-packages/pyx/bitmap.py", line 375, in imagedata
>      data = zlib.compress(data.tobytes(), self.flatecompresslevel)
>    TypeError: 'str' does not support the buffer interface
>
> Can you reproduce this (in 0.13.0 and in trunk)?
> (I also manually tried to apply the change
> http://sourceforge.net/p/pyx/code/3598/
> but this did not help, or I did not apply it correctly).
>
> Nothing urgent, as we won't be moving to python 3 that soon,
> but still a fix or work-around would be nice ...
>
> Many thanks, best,
>
> Arnd
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> PyX-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyx-user
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to