[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 <http://bugs.python.org/issue8

[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

[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 tr

[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

[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 <http://bugs.python.org/issue8

[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() . .

[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 expe

[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 s

[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-p

[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 Walter Woods
Changes by Walter Woods : -- title: httplib getheader() does not work as documented -> httplib getheader() throws error instead of default ___ Python tracker <http://bugs.python.org/iss

[issue8572] httplib getheader() does not work as documented

2010-04-29 Thread Walter Woods
New submission from Walter Woods : Calling HTTPResponse.getheader('Testabnew', 'Default') throws an exception rather than returning default, python 3.1.2. Problem code appears to be line 601 of client.py: def getheader(self, name, default=None): if