Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f0996a9

Browse files
committed
Issue #20208: Clarify some things in the Python porting HOWTO.
Thanks to Rodrigo Bernardo Pimentel, Ondřej Čertík, and Dmitry Shachnev for the feedback leading to the changes.
1 parent c089f70 commit f0996a9

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

Doc/howto/pyporting.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,17 @@ older).
151151
``from __future__ import unicode_literals``
152152
'''''''''''''''''''''''''''''''''''''''''''
153153

154-
If you choose not to use this future statement you should then mark all of your
154+
If you choose to use this future statement then all string literals in
155+
Python 2 will be assumed to be Unicode (as is already the case in Python 3).
156+
If you choose not to use this future statement then you should mark all of your
155157
text strings with a ``u`` prefix and only support Python 3.3 or newer. But you
156158
are **strongly** advised to do one or the other (six_ provides a function in
157159
case you don't want to use the future statement **and** you want to support
158160
Python 3.2 or older).
159161

160162

161-
Bytes literals
162-
''''''''''''''
163+
Bytes/string literals
164+
'''''''''''''''''''''
163165

164166
This is a **very** important one. Prefix Python 2 strings that
165167
are meant to contain bytes with a ``b`` prefix to very clearly delineate
@@ -504,12 +506,13 @@ your time and effort to port your tests to :mod:`unittest`.
504506
Update ``map`` for imbalanced input sequences
505507
'''''''''''''''''''''''''''''''''''''''''''''
506508

507-
With Python 2, ``map`` would pad input sequences of unequal length with
508-
`None` values, returning a sequence as long as the longest input sequence.
509+
With Python 2, when ``map`` was given more than one input sequence it would pad
510+
the shorter sequences with `None` values, returning a sequence as long as the
511+
longest input sequence.
509512

510513
With Python 3, if the input sequences to ``map`` are of unequal length, ``map``
511514
will stop at the termination of the shortest of the sequences. For full
512-
compatibility with ``map`` from Python 2.x, also wrap the sequences in
515+
compatibility with ``map`` from Python 2.x, wrap the sequence arguments in
513516
:func:`itertools.zip_longest`, e.g. ``map(func, *sequences)`` becomes
514517
``list(map(func, itertools.zip_longest(*sequences)))``.
515518

@@ -518,9 +521,8 @@ Eliminate ``-3`` Warnings
518521

519522
When you run your application's test suite, run it using the ``-3`` flag passed
520523
to Python. This will cause various warnings to be raised during execution about
521-
things that 2to3 cannot handle automatically (e.g., modules that have been
522-
removed). Try to eliminate those warnings to make your code even more portable
523-
to Python 3.
524+
things that are semantic changes between Python 2 and 3. Try to eliminate those
525+
warnings to make your code even more portable to Python 3.
524526

525527

526528
Alternative Approaches

0 commit comments

Comments
 (0)