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

Skip to content

Commit 56076da

Browse files
committed
Finished the "porting to 3.0" section. Had to add a label to
howto/cporting.rst.
1 parent 715287f commit 56076da

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

Doc/howto/cporting.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. highlightlang:: c
22

3+
.. _cporting-howto:
4+
35
********************************
46
Porting Extension Modules to 3.0
57
********************************

Doc/whatsnew/3.0.rst

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,9 @@ consulted for longer descriptions.
426426
Library Changes
427427
===============
428428

429+
Due to time constraints, this document does not exhaustively cover
430+
the very extensive changes to the library.
431+
429432
XXX Brief overview of what's changed in the library.
430433

431434
* :pep:`3108`: stdlib reorganization.
@@ -778,16 +781,35 @@ XXX Some of the more notable changes are:
778781
Porting To Python 3.0
779782
=====================
780783

781-
This section lists previously described changes that may require
782-
changes to your code:
784+
For porting existing Python 2.5 or 2.6 source code to Python 3.0, the
785+
best strategy is the following:
786+
787+
0. (Prerequisite:) Start with excellent test coverage.
788+
789+
1. Port to Python 2.6. This should be no more work than the average
790+
port from Python 2.x to Python 2.(x+1). Make sure all your tests
791+
pass.
783792

784-
* Everything is all in the details!
793+
2. (Still using 2.6:) Turn on the :option:`-3` command line switch.
794+
This enables warnings about features that will be removed (or
795+
change) in 3.0. Run your test suite again, and fix code that you
796+
get warnings about until there are no warnings left, and all your
797+
tests still pass.
785798

786-
* Developers can include :file:`intobject.h` after :file:`Python.h` for
787-
some ``PyInt_`` aliases.
799+
3. Run the ``2to3`` source-to-source translator over your source code
800+
tree. (See :ref:`2to3-reference` for more on this tool.) Run the
801+
result of the translation under Python 3.0. Manually fix up any
802+
remaining issues, fixing problems until all tests pass again.
788803

789-
* XXX Mention 2to3.
804+
It is not recommended to try to write source code that runs unchanged
805+
under both Python 2.6 and 3.0; you'd have to use a very contorted
806+
coding style, e.g. avoiding :keyword:`print` statements, metaclasses,
807+
and much more. If you are maintaining a library that needs to support
808+
both Python 2.6 and Python 3.0, the best approach is to modify step 3
809+
above by editing the 2.6 version of the source code and running the
810+
``2to3`` translator again, rather than editing the 3.0 version of the
811+
source code.
790812

791-
* XXX Reference external doc about porting extensions?
813+
For porting C extensions to Python 3.0, please see :ref:`cporting-howto`.
792814

793815
.. ======================================================================

0 commit comments

Comments
 (0)