Re: [Python-Dev] accept string in a2b and base64?

2012-02-22 Thread Martin v. Löwis
> It seems to me that part of the point of the byte/string split (and the > lack of automatic coercion) is to make the programmer be explicit about > converting between unicode and bytes. Having these functions, which > convert between binary formats (ASCII-only representations of binary data > an

[Python-Dev] accept string in a2b and base64?

2012-02-21 Thread Stephen J. Turnbull
R. David Murray writes: > If most people agree with Antoine I won't fight it, but it seems to me > that accepting unicode in the binascii and base64 APIs is a bad > idea. First, I agree with David that this change should have been brought up on python-dev before committing it. The distinction

Re: [Python-Dev] accept string in a2b and base64?

2012-02-21 Thread Nick Coghlan
On Tue, Feb 21, 2012 at 10:28 PM, Antoine Pitrou wrote: > So it's like typing `open(b"LICENSE", "r")`: the fast that `b"LICENSE"` > is bytes while `"r"` is str isn't really a problem. Ah, right - I misunderstood how the different arguments were being used. Cheers, Nick. -- Nick Coghlan   |   n

Re: [Python-Dev] accept string in a2b and base64?

2012-02-21 Thread Antoine Pitrou
On Tue, 21 Feb 2012 12:51:08 +1000 Nick Coghlan wrote: > > My one concern with the base64 patch is that it doesn't test that > mixing types triggers TypeError. While this shouldn't require any > extra code (the error should arise naturally from the method > implementation), it should still be tes

Re: [Python-Dev] accept string in a2b and base64?

2012-02-21 Thread M.-A. Lemburg
Nick Coghlan wrote: > The reason Python 2's implicit str<->unicode conversions are so > problematic isn't just because they're implicit: it's because they > effectively assume *latin-1* as the encoding on the 8-bit str side. The implicit conversion in Python2 only works with ASCII content, pretty

Re: [Python-Dev] accept string in a2b and base64?

2012-02-20 Thread Nick Coghlan
On Tue, Feb 21, 2012 at 11:24 AM, R. David Murray wrote: > If most people agree with Antoine I won't fight it, but it seems to me > that accepting unicode in the binascii and base64 APIs is a bad idea. I see it as essentially the same as the changes I made in urllib.urlparse to support pure ASCII

Re: [Python-Dev] accept string in a2b and base64?

2012-02-20 Thread Antoine Pitrou
On Mon, 20 Feb 2012 20:24:16 -0500 "R. David Murray" wrote: > > It seems to me that part of the point of the byte/string split (and the > lack of automatic coercion) is to make the programmer be explicit about > converting between unicode and bytes. Having these functions, which > convert betwee

[Python-Dev] accept string in a2b and base64?

2012-02-20 Thread R. David Murray
Two patches have been committed to 3.3 that I am very uncomfortable with. See issue 13637 and issue 13641, respectively. It seems to me that part of the point of the byte/string split (and the lack of automatic coercion) is to make the programmer be explicit about converting between unicode and by