This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: subversion keyword breakage
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Neil Muller, georg.brandl, orsenthil, pitrou, python-dev, skrah
Priority: normal Keywords: patch

Created on 2011-03-08 15:10 by skrah, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
SVN_Revision.diff Neil Muller, 2011-07-05 10:48 Replace "$Revision" keywords in 2.7 head review
cleanup_3.3svn_keywords.diff Neil Muller, 2011-07-05 10:56 Remove or replace keywords under Lib review
Messages (11)
msg130335 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2011-03-08 15:10
Several files rely on properly substituted subversion keywords. In
the cpython clone the keywords aren't substituted.


3.3 example:
============

$ find . -name "*.c" | xargs grep -n '"\$'
./Modules/_bsddb.c:102:static char *rcs_id = "$Id$";
./Modules/pyexpat.c:1818:    static char *rcsid = "$Revision$";
./Modules/getbuildinfo.c:28:#define SVNVERSION "$WCRANGE$$WCMODS?M:$"
./Modules/_hotshot.c:1402:    static char *rcsid = "$Revision$";
./Python/sysmodule.c:1147:static const char headurl[] = "$HeadURL$";


Python 3.3a0 (default:a69ef22b60e3, Mar  8 2011, 15:40:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyexpat
>>> pyexpat.__version__
'400s)'
>>> 


2.5 example:
============

Python does not build without at least changing Include/patchlevel.h
and Python/sysmodule.c.
msg130341 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2011-03-08 16:24
See also issue 11421.
msg131097 - (view) Author: Neil Muller (Neil Muller) Date: 2011-03-16 10:28
This also affects a number of files under Lib, including some that set their version using "$Revision$".

Since I stumbled on this issue by encountering some code that checks the version string in tkinker breaking, this is an issue that can break existing code.

Mercurial does have the keyword extension (http://mercurial.selenic.com/wiki/KeywordExtension) which can provide something similar, but should be some sort of recommended configuration for this and there'll be discrepancies between the id's from svn and mercurial (which may or may not be an issue in practice).

find ./Lib -name "*.py" | xargs grep -n '"\$Revision\$"'

./Lib/tarfile.py:32:__version__ = "$Revision$"
./Lib/pydoc.py:45:__version__ = "$Revision$"
./Lib/tkinter/__init__.py:33:__version__ = "$Revision$"
./Lib/pickle.py:26:__version__ = "$Revision$"       # Code version
msg131173 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2011-03-16 20:52
I've also looked at the keyword extension, but for example HeadURL does
not seem to be supported by default:

http://comments.gmane.org/gmane.comp.version-control.mercurial.devel/31214
msg131175 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-03-16 20:57
These "verbose numbers" don't seem to serve a purpose, they should simply be removed (or replaced by a static, non-moving number higher than the highest svn rev).

The keyword extension is generally frown upon, because it introduces complexity, performance issues, and also possibly undesired behaviour.

Endly, I don't think this is a critical issue at all.
msg131176 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-03-16 20:57
"version numbers", not "verbose numbers", sorry.
msg138699 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2011-06-20 11:29
Building matplotlib with the 2.7.2 release fails due to this issue:

Traceback (most recent call last):
  File "setup.py", line 162, in <module>
    if check_for_tk() or (options['build_tkagg'] is True):
  File "/home/stefan/src/matplotlib-1.0.1/setupext.py", line 832, in check_for_tk
    (Tkinter.__version__.split()[-2], Tkinter.TkVersion, Tkinter.TclVersion))
IndexError: list index out of range


Python 2.7.2 (default, Jun 20 2011, 13:19:22) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>> Tkinter.__version__
'$Revision$'
msg139845 - (view) Author: Neil Muller (Neil Muller) Date: 2011-07-05 10:48
SVN_Revision.diff replaces the remaining "$Revision$" keywords in 2.7 with the values from the last SVN checkout I have. This seems the correct minimal fix for the issues caused by code parsing the revision tag in Python 2. I've left the various other keywords untouched in 2.7 (mainly $Id$ tags) untouched, since they appear to be unused.
msg139847 - (view) Author: Neil Muller (Neil Muller) Date: 2011-07-05 10:56
This patch removes or replaces a number SVN keywords which aren't buried in comments.

I've removed '__revision__ = "$Id$"' cases - mainly present in distutils - as no-one appears to using these.

I've replaced values in tarfile.py, but they can probably be removed as well.
msg141304 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-07-28 15:39
New changeset f15442543e24 by Senthil Kumaran in branch '2.7':
Fix closes Issue11439 - Handle the SVN Keywords in 2.7 by replacing them with a high number so that code relying on them does not break.
http://hg.python.org/cpython/rev/f15442543e24

New changeset 3e26c9033306 by Senthil Kumaran in branch '3.2':
Fix closes Issue11439 Remove the SVN keywords from the code as it is no longer applicable in hg. Patch Contributed by Neil Muller.
http://hg.python.org/cpython/rev/3e26c9033306

New changeset 6b9f0a6efaeb by Senthil Kumaran in branch 'default':
merge from 3.2 - Fix closes Issue11439 Remove the SVN keywords from the code as it is no longer applicable in hg. Patch Contributed by Neil Muller.
http://hg.python.org/cpython/rev/6b9f0a6efaeb
msg141305 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-07-28 15:43
Thanks for the patch, Neil.
History
Date User Action Args
2022-04-11 14:57:14adminsetgithub: 55648
2011-07-28 15:43:11orsenthilsetnosy: + orsenthil
messages: + msg141305
2011-07-28 15:39:46python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg141304

resolution: fixed
stage: needs patch -> resolved
2011-07-05 10:56:43Neil Mullersetfiles: + cleanup_3.3svn_keywords.diff

messages: + msg139847
2011-07-05 10:48:57Neil Mullersetfiles: + SVN_Revision.diff
keywords: + patch
messages: + msg139845
2011-06-20 11:29:45skrahsetmessages: + msg138699
2011-06-01 06:28:05terry.reedysetversions: - Python 2.5
2011-03-19 19:07:41skip.montanarosetnosy: - skip.montanaro
2011-03-16 20:57:57pitrousetnosy: skip.montanaro, georg.brandl, pitrou, Neil Muller, skrah
messages: + msg131176
2011-03-16 20:57:38pitrousetpriority: critical -> normal
nosy: skip.montanaro, georg.brandl, pitrou, Neil Muller, skrah
messages: + msg131175
2011-03-16 20:52:42skrahsetnosy: skip.montanaro, georg.brandl, pitrou, Neil Muller, skrah
messages: + msg131173
2011-03-16 10:28:21Neil Mullersetnosy: + Neil Muller
messages: + msg131097
2011-03-08 16:24:26skip.montanarosetnosy: skip.montanaro, georg.brandl, pitrou, skrah
messages: + msg130341
2011-03-08 16:23:43skip.montanarosetnosy: + skip.montanaro
2011-03-08 15:10:20skrahcreate