Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91299 > unrolled thread

Re: Fwd: Lossless bulletproof conversion to unicode (backslashing)

Started byanatoly techtonik <techtonik@gmail.com>
First post2015-05-27 14:52 +0300
Last post2015-05-27 14:52 +0300
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Fwd: Lossless bulletproof conversion to unicode (backslashing) anatoly techtonik <techtonik@gmail.com> - 2015-05-27 14:52 +0300

#91299 — Re: Fwd: Lossless bulletproof conversion to unicode (backslashing)

Fromanatoly techtonik <techtonik@gmail.com>
Date2015-05-27 14:52 +0300
SubjectRe: Fwd: Lossless bulletproof conversion to unicode (backslashing)
Message-ID<mailman.83.1432727585.5151.python-list@python.org>
On Wed, May 27, 2015 at 2:47 PM, anatoly techtonik <techtonik@gmail.com> wrote:
> On Wed, May 27, 2015 at 2:35 PM, Laura Creighton <lac@openend.se> wrote:
>> I am missing something.  Why do you need unicode at all?  Why can you
>> not just keep your binary data as binary data?
>
> Good question. From the SCons code I see that we need unicode, because
> we switched to io.StringIO which is advertised as the future (and Python 3
> way of doing things, because Python 3 doesn't have non-unicode StringIO).
>
> A really deep and exhaustive answer.
> advertisement (first link on StringIO vs io.StringIO):
> http://stackoverflow.com/questions/3410309/what-is-the-difference-between-stringio-and-io-stringio-in-python2-7
> peaceful details
> https://bitbucket.org/scons/scons/commits/05d5af305a5d
> gory consequences
> https://bitbucket.org/scons/scons/pull-request/235/fix-tree-all-print-when-build-tree
>
>> I feel like I must be missing something obvious here ...
>
> Not that obvious as it appears.

And the short answer is that we need unicode because we are printing this
information to the stdout, and stdout is opened in text mode at least on
Windows, and without explicit conversion, Python will try to decode stuff
as being `ascii` and fail anyway.
-- 
anatoly t.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web