Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21353
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: "Decoding unicode is not supported" in unusual situation |
| References | <4f571b94$0$12037$742ec2ed@news.sonic.net> <m2obs890ge.fsf@web.de> <8762egmzfp.fsf@benfinney.id.au> <4f5749bc$0$29989$c3e8da3$5496439d@news.astraweb.com> <4f57b63f$0$11986$742ec2ed@news.sonic.net> |
| Date | 2012-03-08 08:48 +1100 |
| Message-ID | <871up4m69h.fsf@benfinney.id.au> (permalink) |
| Organization | Unlimited download news at news.astraweb.com |
John Nagle <nagle@animats.com> 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 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.
> The Python documentation
> ("http://docs.python.org/library/functions.html#unicode") does not
> mention this. It is therefore necessary to check the type before
> calling "unicode", or catch the undocumented TypeError exception
> afterward.
Yes, this check should not be necessary; calling the ‘unicode’
constructor with an object that's already an instance of ‘unicode’
should just return the object as-is, IMO. It shouldn't matter that
you've specified how decoding errors are to be handled, because in that
case no decoding happens anyway.
Care to report that bug to <URL:http://bugs.python.org/>, John?
--
\ “Those who write software only for pay should go hurt some |
`\ other field.” —Erik Naggum, in _gnu.misc.discuss_ |
_o__) |
Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
"Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-07 00:25 -0800
Re: "Decoding unicode is not supported" in unusual situation deets@web.de (Diez B. Roggisch) - 2012-03-07 11:20 +0100
Re: "Decoding unicode is not supported" in unusual situation Ben Finney <ben+python@benfinney.id.au> - 2012-03-07 22:18 +1100
Re: "Decoding unicode is not supported" in unusual situation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-07 11:42 +0000
Re: "Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-07 11:25 -0800
Re: "Decoding unicode is not supported" in unusual situation Ben Finney <ben+python@benfinney.id.au> - 2012-03-08 08:48 +1100
Re: "Decoding unicode is not supported" in unusual situation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-07 23:26 +0000
Re: "Decoding unicode is not supported" in unusual situation Terry Reedy <tjreedy@udel.edu> - 2012-03-07 19:03 -0500
Re: "Decoding unicode is not supported" in unusual situation Ben Finney <ben+python@benfinney.id.au> - 2012-03-08 13:18 +1100
Re: "Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-08 14:23 -0800
RE: "Decoding unicode is not supported" in unusual situation "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-08 22:58 +0000
Re: "Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-09 10:11 -0800
Re: "Decoding unicode is not supported" in unusual situation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-10 00:57 +0000
Re: "Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-10 22:12 -0800
Re: "Decoding unicode is not supported" in unusual situation Neil Cerutti <neilc@norwich.edu> - 2012-03-09 13:23 +0000
csiph-web