Skip to content
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

Fix reading/writing from urllib.request objects #5910

Merged
merged 2 commits into from
Jan 25, 2016

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Jan 25, 2016

Addresses matplotlib-devel thread "Possible bug in matplotlib versions 1.4 and higher with basemap arcgisimage imagery"

@mdboom mdboom modified the milestone: Critical bug fix release (1.5.2) Jan 25, 2016
@@ -517,6 +517,13 @@ def test_minimized_rasterized():
assert False


@cleanup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this need a @attr('network') decorator too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I forgot we had that.

@mdboom mdboom added this to the Critical bug fix release (1.5.2) milestone Jan 25, 2016
@@ -206,7 +206,17 @@ static PyObject *Py_write_png(PyObject *self, PyObject *args, PyObject *kwds)
goto exit;
}
buff.cursor = 0;
} else if ((fp = mpl_PyFile_Dup(py_file, (char *)"wb", &offset))) {
} else {
#if PY3K
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remembered seeing an article recently imploring that we stop writing if-statements like this that would possibly break in py4.x. The logic really should be checking whether or not it is py2.x, as py2.x should be considered the exception to the rule.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope -- this won't break. Here's the definition of it in mpl_utils.h:

#if PY_MAJOR_VERSION >= 3
#define PY3K 1
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
#else
#define PY3K 0
#endif

I take PY3K to mean "next-gen Python" as it was called before Python 3.0 was even released.

@WeatherGod
Copy link
Member

This all looks good to me. The appveyor failures are the usual ones. Thanks for the quick turnaround! I'll also backport to v1.5.x branch.

WeatherGod added a commit that referenced this pull request Jan 25, 2016
Fix reading/writing from urllib.request objects
@WeatherGod WeatherGod merged commit 3675841 into matplotlib:master Jan 25, 2016
@WeatherGod
Copy link
Member

Ok, actually, the backport isn't totally clean. I wonder why?

@WeatherGod
Copy link
Member

Looks like we never backported this code portion:

     if (filein == Py_None) {
         buff.size = width * height * 4 + 1024;
         buff.str = PyBytes_FromStringAndSize(NULL, buff.size);
         if (buff.str == NULL) {
             goto exit;
         }
         buff.cursor = 0;
     } else {

Was that intentional?

@jenshnielsen
Copy link
Member

Does git blame tell us where it is coming from?

@WeatherGod
Copy link
Member

looks like b3e9443

@jenshnielsen
Copy link
Member

So that traces it to #5389 which is mainly a performance improvement and thus not backported. Not sure how to best handle that

@WeatherGod
Copy link
Member

Looking over it, I wonder if that was the commit that broke things? So,
maybe the bug isn't on v1.5.x?

On Mon, Jan 25, 2016 at 3:37 PM, Jens Hedegaard Nielsen <
notifications@github.com> wrote:

So that traces it to #5389
#5389 which is mainly a
performance improvement and thus not backported. Not sure how to best
handle that


Reply to this email directly or view it on GitHub
#5910 (comment)
.

@jenshnielsen
Copy link
Member

According to the original issue mail the bug is on 1.4.0 and up so I guess that

@WeatherGod
Copy link
Member

hmmm, that's right. How about I take a crack at the backport and come up with a PR for it so that we can double-check that it makes sense?

@jenshnielsen
Copy link
Member

@WeatherGod 👍

@mdboom
Copy link
Member Author

mdboom commented Jan 27, 2016

Looks like we never backported this code portion. Was this intentional?

Yes -- it's an optimization for the nbagg backend. It doesn't make sense to backport that unless we backport the related changes to nbagg (which I wouldn't recommend).

WeatherGod added a commit to WeatherGod/matplotlib that referenced this pull request Jan 27, 2016
Fix reading/writing from urllib.request objects

This backport needed to exclude nbagg optimizations.
@WeatherGod
Copy link
Member

#5927 is my attempt at backporting to v1.5.x

mdboom added a commit that referenced this pull request Jan 27, 2016
Merge pull request #5910 from mdboom/image-read-from-url
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull request May 22, 2016
Fix reading/writing from urllib.request objects

This backport needed to exclude nbagg optimizations.
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull request Jun 30, 2016
Faster image generation in WebAgg/NbAgg backends

Conflicts:
	src/_png.cpp
	  Due to having previously backported matplotlib#5910 ( 3675841 ) as
	  ( 99ad89d )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants