Index: Python/sysmodule.c =================================================================== --- Python/sysmodule.c (revision 41708) +++ Python/sysmodule.c (working copy) @@ -1003,6 +1003,9 @@ PyDict_SetItemString(sysdict, "hexversion", v = PyInt_FromLong(PY_VERSION_HEX)); Py_XDECREF(v); + PyDict_SetItemString(sysdict, "build_number", + v = PyInt_FromLong(Py_GetBuildNumber())); + Py_XDECREF(v); /* * These release level checks are mutually exclusive and cover * the field, so don't get too fancy with the pre-processor! Index: Include/pythonrun.h =================================================================== --- Include/pythonrun.h (revision 41708) +++ Include/pythonrun.h (working copy) @@ -106,6 +106,7 @@ PyAPI_FUNC(const char *) Py_GetCopyright(void); PyAPI_FUNC(const char *) Py_GetCompiler(void); PyAPI_FUNC(const char *) Py_GetBuildInfo(void); +PyAPI_FUNC(int) Py_GetBuildNumber(void); /* Internal -- various one-time initializations */ PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); Index: Doc/lib/libsys.tex =================================================================== --- Doc/lib/libsys.tex (revision 41708) +++ Doc/lib/libsys.tex (working copy) @@ -27,6 +27,11 @@ \versionadded{2.0} \end{datadesc} +\begin{datadesc}{build_number} + An integer representing the Subversion revision that this Python executable + was built from. +\end{datadesc} + \begin{datadesc}{builtin_module_names} A tuple of strings giving the names of all modules that are compiled into this Python interpreter. (This information is not available in Index: Makefile.pre.in =================================================================== --- Makefile.pre.in (revision 41708) +++ Makefile.pre.in (working copy) @@ -348,7 +348,9 @@ $(SIGNAL_OBJS) \ $(MODOBJS) \ $(srcdir)/Modules/getbuildinfo.c - if test -f buildno; then \ + if test -d .svn; then \ + svn info | grep -i revision | cut -f 2 -d " " >buildno; \ + elif test -f buildno; then \ expr `cat buildno` + 1 >buildno1; \ mv -f buildno1 buildno; \ else echo 1 >buildno; fi Index: Modules/getbuildinfo.c =================================================================== --- Modules/getbuildinfo.c (revision 41708) +++ Modules/getbuildinfo.c (working copy) @@ -32,3 +32,9 @@ "#%d, %.20s, %.9s", BUILD, DATE, TIME); return buildinfo; } + +int +Py_GetBuildNumber(void) +{ + return BUILD; +}