@@ -426,6 +426,9 @@ consulted for longer descriptions.
426
426
Library Changes
427
427
===============
428
428
429
+ Due to time constraints, this document does not exhaustively cover
430
+ the very extensive changes to the library.
431
+
429
432
XXX Brief overview of what's changed in the library.
430
433
431
434
* :pep: `3108 `: stdlib reorganization.
@@ -778,16 +781,35 @@ XXX Some of the more notable changes are:
778
781
Porting To Python 3.0
779
782
=====================
780
783
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.
783
792
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.
785
798
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.
788
803
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.
790
812
791
- * XXX Reference external doc about porting extensions?
813
+ For porting C extensions to Python 3.0, please see :ref: ` cporting-howto `.
792
814
793
815
.. ======================================================================
0 commit comments