diff options
author | Andrew Kuchling <amk@amk.ca> | 2015-04-14 10:35:43 -0400 |
---|---|---|
committer | Andrew Kuchling <amk@amk.ca> | 2015-04-14 10:35:43 -0400 |
commit | 3b3863c2d496f01845eda76ccf6401458714397e (patch) | |
tree | 14af5692bc33ffc3a589478b03e33e597ce17166 /Doc/howto/pyporting.rst | |
parent | b6b4ba499008572740b20b22481074263fb4e5d7 (diff) | |
parent | da4c26c69f751f7c0207b009b2372bdc12c08bba (diff) | |
download | cpython-3b3863c2d496f01845eda76ccf6401458714397e.tar.gz |
Merge from 3.4
Diffstat (limited to 'Doc/howto/pyporting.rst')
-rw-r--r-- | Doc/howto/pyporting.rst | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Doc/howto/pyporting.rst b/Doc/howto/pyporting.rst index 5e875cdee2..a2aaf367c7 100644 --- a/Doc/howto/pyporting.rst +++ b/Doc/howto/pyporting.rst @@ -207,13 +207,12 @@ that's ``str``/``bytes`` in Python 2 and ``bytes`` in Python 3). The following table lists the **unique** methods of each data type across Python 2 & 3 (e.g., the ``decode()`` method is usable on the equivalent binary data type in either Python 2 or 3, but it can't be used by the text data type consistently -between Python 2 and 3 because ``str`` in Python 3 doesn't have the method). +between Python 2 and 3 because ``str`` in Python 3 doesn't have the method). Do +note that as of Python 3.5 the ``__mod__`` method was added to the bytes type. ======================== ===================== **Text data** **Binary data** ------------------------ --------------------- -__mod__ (``%`` operator) ------------------------- --------------------- \ decode ------------------------ --------------------- encode @@ -348,10 +347,12 @@ tox with your continuous integration system so that you never accidentally break Python 2 or 3 support. You may also want to use use the ``-bb`` flag with the Python 3 interpreter to -trigger an exception when you are comparing bytes to strings. Usually it's -simply ``False``, but if you made a mistake in your separation of text/binary -data handling you may be accidentally comparing text and binary data. This flag -will raise an exception when that occurs to help track down such cases. +trigger an exception when you are comparing bytes to strings or bytes to an int +(the latter is available starting in Python 3.5). By default type-differing +comparisons simply return ``False``, but if you made a mistake in your +separation of text/binary data handling or indexing on bytes you wouldn't easily +find the mistake. This flag will raise an exception when these kinds of +comparisons occur, making the mistake much easier to track down. And that's mostly it! At this point your code base is compatible with both Python 2 and 3 simultaneously. Your testing will also be set up so that you |