Re: "Decoding unicode is not supported" in unusual situation

2012-03-10 Thread John Nagle
On 3/9/2012 4:57 PM, Steven D'Aprano wrote: On Fri, 09 Mar 2012 10:11:58 -0800, John Nagle wrote: This demonstrates a gross confusion about both Unicode and Python. John, I honestly don't mean to be rude here, but if you actually believe that (rather than merely expressing yourself poorly), then

Re: "Decoding unicode is not supported" in unusual situation

2012-03-09 Thread Steven D'Aprano
On Fri, 09 Mar 2012 10:11:58 -0800, John Nagle wrote: > On 3/8/2012 2:58 PM, Prasad, Ramit wrote: >>> Right. The real problem is that Python 2.7 doesn't have distinct >>> "str" and "bytes" types. type(bytes() returns "str" is >>> assumed to be ASCII 0..127, but that's not enforced. "bytes" a

Re: "Decoding unicode is not supported" in unusual situation

2012-03-09 Thread John Nagle
On 3/8/2012 2:58 PM, Prasad, Ramit wrote: Right. The real problem is that Python 2.7 doesn't have distinct "str" and "bytes" types. type(bytes() returns "str" is assumed to be ASCII 0..127, but that's not enforced. "bytes" and "str" should have been distinct types, but that would have broke

Re: "Decoding unicode is not supported" in unusual situation

2012-03-09 Thread Neil Cerutti
On 2012-03-08, John Nagle wrote: > So it's possible to get junk characters in a "str", and they > won't convert to Unicode. I've had this happen with databases > which were supposed to be ASCII, but occasionally a non-ASCII > character would slip through. Perhaps encode and then decode, rather t

RE: "Decoding unicode is not supported" in unusual situation

2012-03-08 Thread Prasad, Ramit
n Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- > -Original Message- > From: python-list-bounces+ramit.prasad=jpmorgan@python.org > [mailto:python-list-bounces+ramit.prasad=jpmorgan@python.org] On Behalf >

Re: "Decoding unicode is not supported" in unusual situation

2012-03-08 Thread John Nagle
On 3/7/2012 6:18 PM, Ben Finney wrote: Steven D'Aprano writes: On Thu, 08 Mar 2012 08:48:58 +1100, Ben Finney wrote: I think that's a Python bug. If the latter succeeds as a no-op, the former should also succeed as a no-op. Neither should ever get any errors when ‘s’ is a ‘unicode’ object alr

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread Ben Finney
Steven D'Aprano writes: > On Thu, 08 Mar 2012 08:48:58 +1100, Ben Finney wrote: > > I think that's a Python bug. If the latter succeeds as a no-op, the > > former should also succeed as a no-op. Neither should ever get any > > errors when ‘s’ is a ‘unicode’ object already. > > No. The semantics o

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread Terry Reedy
On 3/7/2012 6:26 PM, Steven D'Aprano wrote: On Thu, 08 Mar 2012 08:48:58 +1100, Ben Finney wrote: John Nagle writes: The library bug, if any, is that you can't apply unicode(s, errors='replace') to a Unicode string. TypeError("Decoding unicode is not supported") is raised. How

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread Steven D'Aprano
On Thu, 08 Mar 2012 08:48:58 +1100, Ben Finney wrote: > John Nagle writes: > >>The library bug, if any, is that you can't apply >> >> unicode(s, errors='replace') >> >> to a Unicode string. TypeError("Decoding unicode is not supported") is >> raised. However >> >> unicode(s) >> >>

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread Ben Finney
John Nagle writes: >The library bug, if any, is that you can't apply > > unicode(s, errors='replace') > > to a Unicode string. TypeError("Decoding unicode is not supported") is > raised. However > > unicode(s) > > will accept Unicode input. I think that's a Python bug. If the la

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread John Nagle
On 3/7/2012 3:42 AM, Steven D'Aprano wrote: I *think* he is complaining that some other library -- suds? -- has a broken test for Unicode, by using: if type(s) is unicode: ... instead of if isinstance(s, unicode): ... Consequently, when the library passes a unicode *subclass* to the tounicod

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread Steven D'Aprano
On Wed, 07 Mar 2012 22:18:50 +1100, Ben Finney wrote: > de...@web.de (Diez B. Roggisch) writes: > >> John Nagle writes: >> >> > I think that somewhere in "suds", they subclass the "unicode" type. >> > That's almost too cute. >> > >> > The proper test is >> > >> >isinstance(s,unicode) >> >> W

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread Ben Finney
de...@web.de (Diez B. Roggisch) writes: > John Nagle writes: > > > I think that somewhere in "suds", they subclass the "unicode" type. > > That's almost too cute. > > > > The proper test is > > > > isinstance(s,unicode) > > Woot, you finally discovered polymorphism - congratulations! If by “

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread Diez B. Roggisch
John Nagle writes: > I think that somewhere in "suds", they subclass the "unicode" type. > That's almost too cute. > > The proper test is > > isinstance(s,unicode) Woot, you finally discovered polymorphism - congratulations! Diez -- http://mail.python.org/mailman/listinfo/python-list