{"thread":{"id":"32472","subject":"(unknown)","startedAt":"2012-12-28T16:43:22Z","lastAt":"2012-12-28T19:33:31Z","messageCount":2,"participants":["Eric S. Raymond","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"205591","messageId":"20121228164322.B102B4413A@snark.thyrsus.com","threadId":"32472","inReplyTo":null,"subject":"(unknown)","fromName":"Eric S. Raymond","fromEmail":"esr@thyrsus.com","sentAt":"2012-12-28T16:43:22Z","receivedAt":"2012-12-28T16:43:22Z","isPatch":false,"sender":{"key":"esr@thyrsus.com","avatar":"https://avatars.githubusercontent.com/u/727961?v=4"},"body":"From: \"Eric S. Raymond\" <esr@thyrsus.com>\nDate: Fri, 28 Dec 2012 11:40:59 -0500\nSubject: [PATCH] Add checks to Python scripts for version dependencies.\n\n---\n contrib/ciabot/ciabot.py           | 8 +++++++-\n contrib/fast-import/import-zips.py | 7 ++++++-\n contrib/hg-to-git/hg-to-git.py     | 5 +++++\n contrib/p4import/git-p4import.py   | 5 +++++\n contrib/svn-fe/svnrdump_sim.py     | 4 ++++\n git-p4.py                          | 8 +++++++-\n git-remote-testgit.py              | 5 +++++\n git_remote_helpers/git/__init__.py | 5 +++++\n 8 files changed, 44 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/ciabot/ciabot.py b/contrib/ciabot/ciabot.py\nindex bd24395..81c3ebd 100755\n--- a/contrib/ciabot/ciabot.py\n+++ b/contrib/ciabot/ciabot.py\n@@ -47,7 +47,13 @@\n # we default to that.\n #\n \n-import os, sys, commands, socket, urllib\n+import sys\n+if sys.hexversion < 0x02000000:\n+\t# The limiter is the xml.sax module\n+        sys.stderr.write(\"ciabot.py: requires Python 2.0.0 or later.\\n\")\n+        sys.exit(1)\n+\n+import os, commands, socket, urllib\n from xml.sax.saxutils import escape\n \n # Changeset URL prefix for your repo: when the commit ID is appended\ndiff --git a/contrib/fast-import/import-zips.py b/contrib/fast-import/import-zips.py\nindex 82f5ed3..b989941 100755\n--- a/contrib/fast-import/import-zips.py\n+++ b/contrib/fast-import/import-zips.py\n@@ -9,10 +9,15 @@\n ##  git log --stat import-zips\n \n from os import popen, path\n-from sys import argv, exit\n+from sys import argv, exit, hexversion\n from time import mktime\n from zipfile import ZipFile\n \n+if hexversion < 0x01060000:\n+\t# The limiter is the zipfile module\n+        sys.stderr.write(\"import-zips.py: requires Python 1.6.0 or later.\\n\")\n+        sys.exit(1)\n+\n if len(argv) < 2:\n \tprint 'Usage:', argv[0], '<zipfile>...'\n \texit(1)\ndiff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py\nindex 046cb2b..232625a 100755\n--- a/contrib/hg-to-git/hg-to-git.py\n+++ b/contrib/hg-to-git/hg-to-git.py\n@@ -23,6 +23,11 @@ import os, os.path, sys\n import tempfile, pickle, getopt\n import re\n \n+if sys.hexversion < 0x02030000:\n+   # The behavior of the pickle module changed significantly in 2.3\n+   sys.stderr.write(\"hg-to-git.py: requires Python 2.3 or later.\\n\")\n+   sys.exit(1)\n+\n # Maps hg version -> git version\n hgvers = {}\n # List of children for each hg revision\ndiff --git a/contrib/p4import/git-p4import.py b/contrib/p4import/git-p4import.py\nindex b6e534b..593d6a0 100644\n--- a/contrib/p4import/git-p4import.py\n+++ b/contrib/p4import/git-p4import.py\n@@ -14,6 +14,11 @@ import sys\n import time\n import getopt\n \n+if sys.hexversion < 0x02020000:\n+   # The behavior of the marshal module changed significantly in 2.2\n+   sys.stderr.write(\"git-p4import.py: requires Python 2.2 or later.\\n\")\n+   sys.exit(1)\n+\n from signal import signal, \\\n    SIGPIPE, SIGINT, SIG_DFL, \\\n    default_int_handler\ndiff --git a/contrib/svn-fe/svnrdump_sim.py b/contrib/svn-fe/svnrdump_sim.py\nindex 1cfac4a..95a80ae 100755\n--- a/contrib/svn-fe/svnrdump_sim.py\n+++ b/contrib/svn-fe/svnrdump_sim.py\n@@ -7,6 +7,10 @@ to the highest revision that should be available.\n \"\"\"\n import sys, os\n \n+if sys.hexversion < 0x02040000:\n+\t# The limiter is the ValueError() calls. This may be too conservative\n+        sys.stderr.write(\"svnrdump-sim.py: requires Python 2.4 or later.\\n\")\n+        sys.exit(1)\n \n def getrevlimit():\n         var = 'SVNRMAX'\ndiff --git a/git-p4.py b/git-p4.py\nindex 551aec9..69f1452 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -8,7 +8,13 @@\n # License: MIT <http://www.opensource.org/licenses/mit-license.php>\n #\n \n-import optparse, sys, os, marshal, subprocess, shelve\n+import sys\n+if sys.hexversion < 0x02040000:\n+    # The limiter is the subprocess module\n+    sys.stderr.write(\"git-p4: requires Python 2.4 or later.\\n\")\n+    sys.exit(1)\n+\n+import optparse, os, marshal, subprocess, shelve\n import tempfile, getopt, os.path, time, platform\n import re, shutil\n \ndiff --git a/git-remote-testgit.py b/git-remote-testgit.py\nindex 5f3ebd2..91faabd 100644\n--- a/git-remote-testgit.py\n+++ b/git-remote-testgit.py\n@@ -31,6 +31,11 @@ from git_remote_helpers.git.exporter import GitExporter\n from git_remote_helpers.git.importer import GitImporter\n from git_remote_helpers.git.non_local import NonLocalGit\n \n+if sys.hexversion < 0x01050200:\n+    # os.makedirs() is the limiter\n+    sys.stderr.write(\"git-remote-testgit: requires Python 1.5.2 or later.\\n\")\n+    sys.exit(1)\n+\n def get_repo(alias, url):\n     \"\"\"Returns a git repository object initialized for usage.\n     \"\"\"\ndiff --git a/git_remote_helpers/git/__init__.py b/git_remote_helpers/git/__init__.py\nindex e69de29..1dbb1b0 100644\n--- a/git_remote_helpers/git/__init__.py\n+++ b/git_remote_helpers/git/__init__.py\n@@ -0,0 +1,5 @@\n+import sys\n+if sys.hexversion < 0x02040000:\n+    # The limiter is the subprocess module\n+    sys.stderr.write(\"git_remote_helpers: requires Python 2.4 or later.\\n\")\n+    sys.exit(1)\n-- \n1.8.1.rc2\n\n\n\n\n-- \n\t\t<a href=\"http://www.catb.org/~esr/\">Eric S. Raymond</a>\n\nA ``decay in the social contract'' is detectable; there is a growing\nfeeling, particularly among middle-income taxpayers, that they are not\ngetting back, from society and government, their money's worth for\ntaxes paid. The tendency is for taxpayers to try to take more control\nof their finances...\t-- IRS Strategic Plan, (May 1984)\n"},{"id":"205599","messageId":"7vk3s2hsz8.fsf@alter.siamese.dyndns.org","threadId":"32472","inReplyTo":"20121228164322.B102B4413A@snark.thyrsus.com","subject":"Re: (unknown)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-28T19:33:31Z","receivedAt":"2012-12-28T19:33:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"esr@thyrsus.com (Eric S. Raymond) writes:\n\n> From: \"Eric S. Raymond\" <esr@thyrsus.com>\n> Date: Fri, 28 Dec 2012 11:40:59 -0500\n> Subject: [PATCH] Add checks to Python scripts for version dependencies.\n>\n> ---\n>  contrib/ciabot/ciabot.py           | 8 +++++++-\n> ...\n> diff --git a/contrib/fast-import/import-zips.py b/contrib/fast-import/import-zips.py\n> index 82f5ed3..b989941 100755\n> --- a/contrib/fast-import/import-zips.py\n> +++ b/contrib/fast-import/import-zips.py\n> @@ -9,10 +9,15 @@\n>  ##  git log --stat import-zips\n>  \n>  from os import popen, path\n> -from sys import argv, exit\n> +from sys import argv, exit, hexversion\n>  from time import mktime\n>  from zipfile import ZipFile\n>  \n> +if hexversion < 0x01060000:\n\nI am assuming that you are carefully limiting what you import from\n\"sys\" by adding only hexversion to the import above, but then can we\nrefer to sys.stderr below?\n\n> +\t# The limiter is the zipfile module\n> +        sys.stderr.write(\"import-zips.py: requires Python 1.6.0 or later.\\n\")\n> +        sys.exit(1)\n> +\n"}]}