Changes between Initial Version and Version 1 of Ticket #24186, comment 5


Ignore:
Timestamp:
11/10/17 14:32:23 (23 months ago)
Author:
embray
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24186, comment 5

    initial v1  
    1 If it helps clarify--the reason for my logic here is that the areas where it is most common to want to convert between bytes/unicode is at the boundary of system functions.  On Python 2 the tradition here is "`str` in `str` out".  This can cause problems of course, which is why the unicode model was changed so drastically on Python 3.  But the fact remains, unless there was a specific reason to convert from `str` at the "out" end (for example, we know we're receiving non-ASCII encoded text), usually "`str` in `str` out" is the default on Python 2.
     1If it helps clarify--the reason for my logic here is that the areas where it is most common to want to convert between bytes/unicode is at the boundary of system functions.  On Python 2 the tradition here is "`str` in `str` out".  This can cause problems of course, which is why the unicode model was changed so drastically on Python 3.  But the fact remains, unless there was a specific reason to convert from `str` to `unicode` at the "out" end (for example, we know we're receiving non-ASCII encoded text), usually "`str` in `str` out" is the default on Python 2.
    22
    33However on Python 3 things are very different--we still want, in most cases "`str` in `str` out".  This is because users and developers are simply more used to dealing with `str` (that is, the object created with `""` or `''` literals without any prefixes).  But on Python 3 this means we have to explicitly handle the "unicode" sandwich "`str` -> `bytes` -> <system> -> `bytes` -> `str`".