Differences between revisions 1 and 19 (spanning 18 versions)
Revision 1 as of 2010-08-20 19:13:38
Size: 996
Editor: 99-68-149-237
Comment:
Revision 19 as of 2010-08-20 22:16:39
Size: 3417
Editor: 99-68-149-237
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
We're really just getting started.   * We're really just getting started.
  * [[http://www.logilab.org/ticket/19645|Here's the ticket about the port]]
Line 7: Line 8:
The idea is to eliminate Python 2.4 compatibility because that will simplify some of the code, and to expand compatibility to 3.0 and 3.1.
  This will require moving logilab common, logilab astng and pylint itself to python 3 using 2to3
  There appear to be test suites for each of these, which can be invoked using the pytest command, which in turn appears to be part of logilab-common itself
  The owners of the code would like to keep the changes compatible with Python 2.5.x, which of course is a bit more involved than targeting 2.6 and up.
The idea is to add support for Python 3.0 and 3.1, while eliminating Python 2.4 compatibility because that will simplify some of the code.
  * This will require one of the following methods:
    * Converting the three Python 2-compatible packages to a common subset of Python 2 and Python 3
      * We may or may not be able to do this using 2to3; 2to3 may or may not prove too exuberant about moving to a nice, python 3-only syntax in some areas.
    * Creating creating modules that abstract the differences between Python 2 and Python 3 and depending on them instead.
  * About the three packages
    * Those three packages are:
      1. logilab-common
        * This one is probably the place to start, because it appears to contain the test harness we need.
        * The owners of the code believe this will be the easiest part
        * 29274 lines of code initially
      1. logilab-astng
        * 18928 lines of code initially
      1. pylint itself
         * 28415 lines of code initially
    * There appear to be test suites for each of these, which can be invoked using the pytest command - pytest appears to be part of logilab-common, which suggests a bit of
      mutual dependency to work around.
  * The owners of the code would like to keep the changes compatible with Python 2.5.x to avoid having two code bases to maintain, which of course is a bit more involved
    than targeting 2.6 and up.
Line 13: Line 29:
* [[http://docs.python.org/library/2to3.html|2to3 documentation]]

* [[http://mercurial.selenic.com/wiki/Py3kPort|Status of the "port" of Mercurial to Py3k]]

* [[http://www.dwheeler.com/essays/python3-in-python2.html|Python 3 in Python 2.6+]]
These are all things related to doing python 2 -> python 3 ports:
  * 2to3
    * [[http://docs.python.org/library/2to3.html|2to3 documentation]]
    * Python Wiki on [[2to3]]
  * Notes about how to do 2 to 3 ports
    * [[http://lucumr.pocoo.org/2010/2/11/porting-to-python-3-a-guide|Porting to Python 3: A Guide]]
    * [[http://www.dwheeler.com/essays/python3-in-python2.html|Python 3 in Python 2.6+]]
    * [[http://www.slideshare.net/regebro/python-3-compatibility-pycon-2009|Pycon 2009: Python 3 Compatibility]] (It's a movie of slides, but there's a transcript below that
      on the page)
  * Specific projects' notes on their ports
    * [[PortingDjangoTo3k|Django]]
    * [[http://mercurial.selenic.com/wiki/Py3kPort|Mercurial]]
    * [[http://web.archiveorange.com/archive/v/mvjb4khRLlhPNkSzNuNt|Bazaar]]
  * The main issues appear to be:
    * Integer division coerces to a float for non-integral values
      * Use int(x/y) instead of x/y
    * Exceptions are a bit different
      * string exceptions are gone
      * {{{
        try:
          print(1/0)
        except:
          e = ...
        }}}
    * str -> bytes, unicode -> str
      * This one's a mess
    * print function instead of statement
      * Use file_.write() instead of print
      * print(var1, var2) happens to work in Python 2, though it doesn't respect some of python 3's options
    * Some things that returned lists, now return iterators. Some things that returned iterators, are gone (or rather, renamed to what formerly returned a list). Example workaround:
      {{{
      try:
        iter = d.iteritems()
      except AttributeError:
        iter = d.items()
      }}}

This page describes efforts to port pylint to Python 3.x

Status of the port

Goals and high level overview of tasks

The idea is to add support for Python 3.0 and 3.1, while eliminating Python 2.4 compatibility because that will simplify some of the code.

  • This will require one of the following methods:
    • Converting the three Python 2-compatible packages to a common subset of Python 2 and Python 3
      • We may or may not be able to do this using 2to3; 2to3 may or may not prove too exuberant about moving to a nice, python 3-only syntax in some areas.
    • Creating creating modules that abstract the differences between Python 2 and Python 3 and depending on them instead.
  • About the three packages
    • Those three packages are:
      1. logilab-common
        • This one is probably the place to start, because it appears to contain the test harness we need.
        • The owners of the code believe this will be the easiest part
        • 29274 lines of code initially
      2. logilab-astng
        • 18928 lines of code initially
      3. pylint itself
        • 28415 lines of code initially
    • There appear to be test suites for each of these, which can be invoked using the pytest command - pytest appears to be part of logilab-common, which suggests a bit of
      • mutual dependency to work around.
  • The owners of the code would like to keep the changes compatible with Python 2.5.x to avoid having two code bases to maintain, which of course is a bit more involved
    • than targeting 2.6 and up.

Resources

These are all things related to doing python 2 -> python 3 ports:

  • 2to3
  • Notes about how to do 2 to 3 ports
  • Specific projects' notes on their ports
  • The main issues appear to be:
    • Integer division coerces to a float for non-integral values
      • Use int(x/y) instead of x/y
    • Exceptions are a bit different
      • string exceptions are gone
      •         try:
                  print(1/0)
                except:
                  e = ...
    • str -> bytes, unicode -> str

      • This one's a mess
    • print function instead of statement
      • Use file_.write() instead of print
      • print(var1, var2) happens to work in Python 2, though it doesn't respect some of python 3's options
    • Some things that returned lists, now return iterators. Some things that returned iterators, are gone (or rather, renamed to what formerly returned a list). Example workaround:
      •       try:
                iter = d.iteritems()
              except AttributeError:
                iter = d.items()

PyLint-3k (last edited 2019-12-15 07:56:25 by FrancesHocutt)

Unable to edit the page? See the FrontPage for instructions.