[issue8572] httplib getheader() throws error instead of default

2010-08-02 Thread Senthil Kumaran
Senthil Kumaran added the comment: David, your suggested description was much better. Modified the documentation in r83529 and r83530. -- status: open -> closed ___ Python tracker __

[issue8572] httplib getheader() throws error instead of default

2010-08-02 Thread R. David Murray
R. David Murray added the comment: Right, the join behavior is correct. But the definition of a *default* (aka sentinel) value is that it is returned *unchanged*. It is counter intuitive that if you pass a list of strings as a default, that what you get back is those strings joined by ','.

[issue8572] httplib getheader() throws error instead of default

2010-08-02 Thread Senthil Kumaran
Senthil Kumaran added the comment: Fixed in revision 83521 (py3k) and 83522 (release31-maint). I made slight modifications to the patch to include non-iterable values,like int, for default too. If you feel the documentation could be made better, please suggest the wordings for the sentence. I

[issue8572] httplib getheader() throws error instead of default

2010-08-01 Thread R. David Murray
R. David Murray added the comment: I'm changing this to release blocker because I don't want to see the erroneous behavior make it into 3.2. -- priority: high -> release blocker ___ Python tracker

[issue8572] httplib getheader() throws error instead of default

2010-08-01 Thread R. David Murray
R. David Murray added the comment: Joining the iterator contents if default is an iterator is an ugly backward compatibility hack. The default should really be returned unchanged. But given there is code in the field working around the current bug, I guess we have to retain it. Of course,

[issue8572] httplib getheader() throws error instead of default

2010-08-01 Thread Walter Woods
Walter Woods added the comment: Sigh. I meant ``or not`` instead of ``or``. Clearly, not having an iterator would be a case to not iterate over the default :) -- ___ Python tracker __

[issue8572] httplib getheader() throws error instead of default

2010-08-01 Thread Walter Woods
Walter Woods added the comment: Hi David, I like most of your patch (especially since it has unit tests), and if people like yourself are actually using the current functionality then that's fine, but one recommendation: why not change this line: if not headers or isinstance(headers, str):

[issue8572] httplib getheader() throws error instead of default

2010-07-31 Thread David Stanek
David Stanek added the comment: Adding a patch that includes a documentation change. -- Added file: http://bugs.python.org/file18302/8572-with-docs.diff ___ Python tracker ___ __

[issue8572] httplib getheader() throws error instead of default

2010-07-31 Thread David Stanek
David Stanek added the comment: I created some tests for the existing behavior and the expected behavior. One of my apps was passing in a tuple and the default. Since this already worked and there are probably others besides me expecting this behavior I changed the patch to handle this. The

[issue8572] httplib getheader() throws error instead of default

2010-06-12 Thread Shashwat Anand
Changes by Shashwat Anand : -- nosy: +l0nwlf ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue8572] httplib getheader() throws error instead of default

2010-06-12 Thread Éric Araujo
Changes by Éric Araujo : -- keywords: +easy ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue8572] httplib getheader() throws error instead of default

2010-06-12 Thread Éric Araujo
Changes by Éric Araujo : -- keywords: -easy nosy: +merwok ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:

[issue8572] httplib getheader() throws error instead of default

2010-05-05 Thread Walter Woods
Walter Woods added the comment: I'll add unit tests later if no one else gets to it first; and they have the same functionality, but I could change the default back to None and use is None if that would be clearer (it would). -- ___ Python tracker

[issue8572] httplib getheader() throws error instead of default

2010-05-05 Thread R. David Murray
R. David Murray added the comment: Given what we've learned, I think that Walter's first patch is the best fix. No one should be relying on the current actual behavior of the default argument, and the fix makes it work as documented. As for backporting to 2.7, I don't think so. 2.7 is in fe

[issue8572] httplib getheader() throws error instead of default

2010-05-05 Thread Walter Woods
Walter Woods added the comment: And if you really think that the unfortunate behavior of >>> getheader('a', ['a', 'b']) 'a, b' Is desired, issue8572-unfortunate.diff retains that behavior. I think that is counter-intuitive though, and it is doubtful that many would be relying on this

[issue8572] httplib getheader() throws error instead of default

2010-05-05 Thread Walter Woods
Walter Woods added the comment: Relevant part from trunk/Lib/rfc822.py illustrating that returning default unchanged is the legacy/defined behavior: return self.dict.get(name.lower(), default) See attached patch for py3k. This preserves backwards compatibility (aside from the comma-

[issue8572] httplib getheader() throws error instead of default

2010-05-05 Thread Walter Woods
Walter Woods added the comment: Senthil, you are correct, I gave a bad example. However, try list()ing an integer :) -- ___ Python tracker ___ _

[issue8572] httplib getheader() throws error instead of default

2010-05-05 Thread Senthil Kumaran
Senthil Kumaran added the comment: Walter, just to address one of your point: +if failobj and not isinstance(failobj, list): +if isinstance(failobj, str): +failobj = [failobj] +else: +failobj = list(failobj)

[issue8572] httplib getheader() throws error instead of default

2010-05-05 Thread Walter Woods
Walter Woods added the comment: Sorry I'm just getting back to this . . . Senthil, doesn't list(None) throw an exception? That was the whole problem with list()ing the default argument. And I don't think the problem should be fixed in email.message.Message.get_all() . . . that function works

[issue8572] httplib getheader() throws error instead of default

2010-05-01 Thread Senthil Kumaran
Senthil Kumaran added the comment: previous patch had a typo and a mistake. uploading the correct one. -- Added file: http://bugs.python.org/file17166/issue8572.diff ___ Python tracker _

[issue8572] httplib getheader() throws error instead of default

2010-05-01 Thread Senthil Kumaran
Changes by Senthil Kumaran : Removed file: http://bugs.python.org/file17165/issue8572.diff ___ Python tracker ___ ___ Python-bugs-list mailing

[issue8572] httplib getheader() throws error instead of default

2010-05-01 Thread Senthil Kumaran
Senthil Kumaran added the comment: It seems that 3.x behavior is correct. I am quoting a relevant section from rfc 2616. """ It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each sub

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread Senthil Kumaran
Senthil Kumaran added the comment: On Fri, Apr 30, 2010 at 01:56:01AM +, R. David Murray wrote: > > I seem to have been missing some context here. I was referring to Walter's comment on default being an int, like HTTPResponse.getheader('Fake-Content-Length',default=42). It was surprising

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread R. David Murray
R. David Murray added the comment: I seem to have been missing some context here. I now understand that this is a regression relative to Python 2.x. It seems to me that the translation from rfc822.Message to email.Message was done incorrectly. In the 2.x code getheader returns only the val

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread Walter Woods
Walter Woods added the comment: Little more info: The actual snippet from couchdb-python is: if int(resp.getheader('content-length', sys.maxsize)) < CHUNK_SIZE: Which should be valid python . . . calling int() on an integer should work, and calling int() on a string expected to be an integ

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread Walter Woods
Walter Woods added the comment: couchdb-python makes http requests, yes. Passing in a number might be mildly inappropriate, BUT I'd like to point out that the default might be used to find out if the header is not set (hence its default value of None). It should not assume that a string

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread R. David Murray
R. David Murray added the comment: @senthil: I'm not quite sure what your sentence referencing couchdb is getting at, but the headers that are being queried are in an email.Message object, and contain only string values unless some code is misusing the API and setting new non-string values af

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread Senthil Kumaran
Senthil Kumaran added the comment: And also, the code which is using getheader of HTTPResponse object would mostly (but incorrectly in py3k) be passing a string as default. The HTTP headers have been a dict with key,values as strings. Counchdb-python - does this make HTTP reqs? I am not sure

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread R. David Murray
R. David Murray added the comment: No, because my code is a backward compatibility hack. Currently if someone is passing a default successfully they must be doing it by passing in a list or tuple consisting of one or more strings. So your code would result in something like: >>> ', '.joi

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread Walter Woods
Walter Woods added the comment: David: Your example tests specifically for a string, but what about just converting default to a string always if it's not a list? Otherwise the string join is just going to fail anyway (suppose an integer is passed, which is the case with couchdb-python). Wo

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread Senthil Kumaran
Senthil Kumaran added the comment: Walter, have a look at http://www.python.org/dev/ document. It is really easy and attach it when its ready. 1) Create a patch against trunk (or py3k). 2) Patch against trunk/ or (py3k/ if its py3k only) 3) Lib/test/test_httplib.py might have similar tests, so

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread Walter Woods
Walter Woods added the comment: Good point. Yeah, I could do that within a week or two at the latest. Just attach a .patch here when done? And, what should the base be for the patch . . . the Lib/http directory? Never submitted anything to python before. -- __

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread R. David Murray
R. David Murray added the comment: For backward compatibility this would have to be something more like: if not isinstance(default, list): if isinstance(default, string): default = [default] else: default = list(default) return ', '.join(self.header

[issue8572] httplib getheader() throws error instead of default

2010-04-29 Thread Walter Woods
Changes by Walter Woods : -- title: httplib getheader() does not work as documented -> httplib getheader() throws error instead of default ___ Python tracker ___