Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix #4154: Return a writable buffer from conv_color #4163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2015

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Feb 25, 2015

No description provided.

@mdboom mdboom added this to the next major release milestone Feb 25, 2015
@OceanWolf
Copy link
Member

Nope, I still get it...

git fetch
git checkout
python setup.py develop

Add an: assert(type(buf) == buffer) after the im.color_conv call, like

rows, cols, buf = im.color_conv (BYTE_FORMAT)
assert(type(buf) == buffer)
surface = ...

I think it should return a buffer type anyway due to unicode issues between 2 and 3.

@OceanWolf
Copy link
Member

Okay, I have got it to work by doing this as a workaround in backend_cairo.py:

rows, cols, buf = im.color_conv (BYTE_FORMAT)
buf = bytearray(buf)

Not the best fix as I think this just sticks a plaster over a problem with the C code not returning the right type.

@mdboom
Copy link
Member Author

mdboom commented Feb 25, 2015

I'd prefer not to return a buffer type from C, since it's been deprecated on Python 3 (honestly, GtkCairo shouldn't be using it anymore, but that's what we've got to work with here). Instead, the best we can do is return something that GtkCairo can turn into a buffer object, in this case a bytearray. So we know from your assert that it's not a buffer, but what is it? Still a str? It should be a bytearray if everything got recompiled correctly. And from your suggested fix, we know that Cairo takes a bytearray just fine.

I'm surprised it's not working for you. Can you go a git clean -fxd first? python setup.py develop is really flaky about rebuilding enough C code.

@mdboom
Copy link
Member Author

mdboom commented Feb 25, 2015

Also, it may be that you're not building this branch, from what you said above:

git fetch
git checkout

@OceanWolf
Copy link
Member

Yes, it still gave me a string... I will try doing a clean :).

I left out the specific names from the commands above:

git fetch master pull/4164/head:pr4154-fix-cairo-buffer
git checkout pr4154-fix-cairo-buffer

@OceanWolf
Copy link
Member

Okay, it works now for me 👍 it would help if I didn't make a 2nd typo in the PR name.

I get back buf of type <type 'bytearray'>

@mdboom mdboom self-assigned this Feb 25, 2015
@OceanWolf
Copy link
Member

One more thing, did you mean to set the milestone for this as next major release, or next point release?

Oh, and Travis seems rather silent now...

@mdboom
Copy link
Member Author

mdboom commented Feb 25, 2015

The bug only exists on master, so it doesn't matter whether it's next major release or point release.

Travis seems to be universally stuck today -- not sure why.

@tacaswell tacaswell modified the milestones: next point release, next major release Feb 25, 2015
@tacaswell
Copy link
Member

I have an email draft I have not sent out yet, but 'next point' -> 2.1, 'next major' -> 3.0, 'color overhaul' -> 2.0

@mdboom mdboom modified the milestones: Color overhaul, next point release Feb 25, 2015
@OceanWolf
Copy link
Member

Re Travis, they have bugs of their own http://www.traviscistatus.com/

@tacaswell tacaswell changed the title Fix #4154: Return a writable buffer from conv_color Fix #4154: Return a writable buffer from conv_color [backport to cover_overhaul] Feb 27, 2015
@tacaswell
Copy link
Member

@mdboom If it is only on master, we don't need to backport this to color_overhaul which is based on 1.4.3.

@OceanWolf
Copy link
Member

@tacaswell cover overhaul, or color overhaul?

@tacaswell tacaswell changed the title Fix #4154: Return a writable buffer from conv_color [backport to cover_overhaul] Fix #4154: Return a writable buffer from conv_color [backport to color_overhaul] Feb 27, 2015
@tacaswell
Copy link
Member

color. Interesting typo there...

@mdboom mdboom modified the milestones: next point release, Color overhaul Feb 27, 2015
@OceanWolf
Copy link
Member

Hmm, this never got merged, do I have the permissions to restart a Travis build? If so, how do I do that?

@tacaswell
Copy link
Member

If go to travis.ci there should be a 'log in with github' link in the tippy top right and give it access to your public repos. Once you are logged in, the build will have a 'restart' button in the top right (but a bit lower than the login).

@OceanWolf
Copy link
Member

Odd, I don't see a link, on the travis profile page it says:



    You are not currently a member of
    any organization.

Is an organization missing?
Review and add your authorized Orgs.

but git hub says travis has access, hmph...

@efiring
Copy link
Member

efiring commented May 15, 2015

I restarted it.

@efiring
Copy link
Member

efiring commented May 15, 2015

@mdboom, I gather from your comment that this does not need to be backported to color_overhaul--but the title and milestone still indicate that it does need to be backported. Would you clarify this, please?

@tacaswell tacaswell changed the title Fix #4154: Return a writable buffer from conv_color [backport to color_overhaul] Fix #4154: Return a writable buffer from conv_color Jun 16, 2015
tacaswell added a commit that referenced this pull request Jun 16, 2015
Fix: Return a writable buffer from conv_color
@tacaswell tacaswell merged commit 2a028c0 into matplotlib:master Jun 16, 2015
@QuLogic QuLogic mentioned this pull request Oct 31, 2015
@mdboom mdboom deleted the gtkcairo-imshow branch November 9, 2015 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants