[Python-Dev] Expose Subversion revision number to Python

Armin Rigo arigo at tunes.org
Fri Dec 16 11:20:24 CET 2005


Hi Barry,

On Fri, Dec 16, 2005 at 12:16:49AM -0500, Barry Warsaw wrote:
> SF patch # 1382163 is a fairly simple patch to expose the Subversion
> revision number to Python, both in the Py_GetBuildInfo() text, and in a
> new Py_GetBuildNumber() C API function, and via a new sys.build_number
> attribute.

I have a minor concern about people starting to use sys.build_number to
check for features in their programs, instead of using sys.version_info
or hasattr() or whatever is relevant -- e.g. because it seems to them
that comparing a single number is easier than a tuple.  The problem is
that this build number would most likely have no meaning in non-CPython
implementations.

What about having instead:

    sys.build_info = ("CPython", <svn rev>, "trunk")

This would make it clear that it's the CPython svn rev number, and it
could possibly be used to distinguish between branches, too, which the
revision number alone cannot do.  ("trunk" is the last part of the path
returned by "svn info".)

Of course, what I'm trying to sneak in here is that it may be a good
occasion to introduce an official way to determine which Python
implementation the program is running on top of -- something more
immediate than the sys.platform=="java" occasionally used in the test
suite to look for Jython.  (I know programs should not depend on this in
general; I'm more thinking about places like the test suite.)


A bientot,

Armin


More information about the Python-Dev mailing list