[Pkg-bazaar-commits] ./bzr/unstable r443: - Patch from Fredrik Lundh to check Python version and

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:19:39 UTC 2009


------------------------------------------------------------
revno: 443
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Tue 2005-05-10 18:15:58 +1000
message:
  - Patch from Fredrik Lundh to check Python version and 
    try to find a better one if it's too old.
  
    Patched to try to prevent infinite loops in wierd configurations,
    and to log to stderr.
modified:
  NEWS
  bzr
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2005-05-10 07:15:48 +0000
+++ b/NEWS	2005-05-10 08:15:58 +0000
@@ -36,6 +36,9 @@
     * New "stat cache" avoids reading the contents of files if they 
       haven't changed since the previous time.
 
+    * If the Python interpreter is too old, try to find a better one
+      or give an error.  Based on a patch from Fredrik Lundh.
+
   
   BUG FIXES:
 

=== modified file 'bzr'
--- a/bzr	2005-03-19 08:19:38 +0000
+++ b/bzr	2005-05-10 08:15:58 +0000
@@ -1,6 +1,5 @@
 #! /usr/bin/env python
 
-# Copyright (C) 2004, 2005 by Martin Pool
 # Copyright (C) 2005 by Canonical Ltd
 
 # This program is free software; you can redistribute it and/or modify
@@ -17,9 +16,32 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import sys, bzrlib, bzrlib.commands
-
+import os, sys
+
+try:
+    version_info = sys.version_info
+except AttributeError:
+    version_info = 1, 5 # 1.5 or older
+
+
+REINVOKE = "__BZR_REINVOKE"    
+NEED_VERS = (2, 3)
+
+if version_info < NEED_VERS:
+    if not os.environ.has_key(REINVOKE):
+        # mutating os.environ doesn't work in old Pythons
+        os.putenv(REINVOKE, "1")
+        for python in 'python2.4', 'python2.3':
+            try:
+                os.execvp(python, [python] + sys.argv)
+            except OSError:
+                pass
+    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
+    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
+    sys.exit(1)
+os.unsetenv(REINVOKE)
+
+import bzrlib, bzrlib.commands
 
 if __name__ == '__main__':
     sys.exit(bzrlib.commands.main(sys.argv))
-    



More information about the Pkg-bazaar-commits mailing list