A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-January/131784.html below:

[Python-Dev] Migration from Python 2.7 and bytes formatting

[Python-Dev] Migration from Python 2.7 and bytes formatting [Python-Dev] Migration from Python 2.7 and bytes formattingNeil Schemenauer nas at arctrix.com
Fri Jan 17 21:09:45 CET 2014
I've refined this idea a little in my latest PEP 461 patch (issue
20284).  Continuing to use %s instead of introducing %b seems
better.  I've called the commmand-line option -2, it could be used
to enable other similar porting aids.

I'd like to try porting code making use of the -2 feature to see how
helpful it is.  The behavior is partway between Python 2.x laziness
and Python 3.x strictness in terms of specifying encodings.

Python 2.x:

    - coerce byte strings to unicode strings to avoid making a
      decision about encoding

    - when writing a unicode string to a bytes stream without
      a specified encoding, encode with ASCII.  Blow up with an
      exception if a non-ASCII character is encounted, often far
      from where the real bug is.

Python 3.x:

    - refuse to accept unicode strings where bytes are expected,
      require explicit encoding to be preformed

Python 3.x with -2 command-line option:

    - when objects are formatted into bytes, immediately
      encode them using strict ASCII encoding.

No code would be considered fully ported to Python 3 unless it can
run without the -2 command line option.

  Neil

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4