Passing a CookieJar instead of a cookieproc to urllib2.build_opener

R

rrenaud

urllib2.build_opener happily accepts and ignores a FileCookieJar. I
had a bug in my code which looked like

urllib2.build_opener(func_returning_cookie_jar())

which should have been

urllib2.build_opener(HTTPCookieProcessor(func_returning_cookie_jar())

The problem is that the code ran happily without actually sending the
cookie, the CookieJar was just ignored. I think that build_opener
should throw an exception when add_handler doesn't actually add.

Is this worth filing a bug for, or is it acceptable behavior?
 
J

John J. Lee

urllib2.build_opener happily accepts and ignores a FileCookieJar. I
had a bug in my code which looked like

urllib2.build_opener(func_returning_cookie_jar())

which should have been

urllib2.build_opener(HTTPCookieProcessor(func_returning_cookie_jar())

The problem is that the code ran happily without actually sending the
cookie, the CookieJar was just ignored. I think that build_opener
should throw an exception when add_handler doesn't actually add.

Is this worth filing a bug for, or is it acceptable behavior?

IMO, it's worth filing iff:

a) you think it's worthwhile (this one sounds worthwhile to me)

b) you write a patch and are prepared to patiently keep at it until it
gets applied

Make sure your patch follows PEP 8. Make sure the patch includes test
and documentation updates / additions (you don't need to write docs in
LaTeX format -- other people will do the conversion to LaTeX for you
if you like). If there are no doc changes required, state that
explicitly in the patch tracker. If your patch gets ignored, review
five other patches, and post to python-dev stating you have done so
and requesting that your patch is reviewed (there's a shortage of
patch reviewers).


John
 
R

rrenaud

IMO, it's worth filing iff:

a) you think it's worthwhile (this one sounds worthwhile to me)

b) you write a patch and are prepared to patiently keep at it until it
gets applied

Make sure your patch follows PEP 8. Make sure the patch includes test
and documentation updates / additions (you don't need to write docs in
LaTeX format -- other people will do the conversion to LaTeX for you
if you like). If there are no doc changes required, state that
explicitly in the patch tracker. If your patch gets ignored, review
five other patches, and post to python-dev stating you have done so
and requesting that your patch is reviewed (there's a shortage of
patch reviewers).

John

The patch is on the tracker here.
http://sourceforge.net/tracker/index.php?func=detail&aid=1750931&group_id=5470&atid=305470

Are the docs themselves in subversion? I suppose I should also update
the doc at http://docs.python.org/lib/module-urllib2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top