The attached patch calculates and exposes the Subversion build number, if available, to Python. If not building Python from a Subversion checkout, the old build number algorithm is used (although it is still newly exposed to Python via sys.build_number).