subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danie...@apache.org
Subject svn commit: r1661247 - in /subversion/trunk: build/generator/gen_base.py build/getversion.py build/transform_sql.py gen-make.py subversion/tests/libsvn_subr/subst_translate-test.c
Date Fri, 20 Feb 2015 23:59:51 GMT
Author: danielsh
Date: Fri Feb 20 23:59:50 2015
New Revision: 1661247

URL: http://svn.apache.org/r1661247
Log:
autogen.sh: Support Python 3.  All Python versions previously supported
remain supported.

Review by: rhuijben, brane

* build/generator/gen_base.py
  (GeneratorBase.write_file_if_changed):
    Convert str to bytes.  Document argument type.

* build/getversion.py
  (traceback): Import.
  (svn_extractor, sqlite_extractor):
    Rewrite 'except' statements in a syntax compatible with both Python 2.5
    and Python 3.  No functional change.

* gen-make.py:
    Ditto.

* build/transform_sql.py
  (Processor.process_file): Use dict.items() instead of dict.iteritems().

* subversion/tests/libsvn_subr/subst_translate-test.c
  (test_svn_subst_translate_string2_null_encoding_helper):
    Convert comment to ASCII.

Modified:
    subversion/trunk/build/generator/gen_base.py
    subversion/trunk/build/getversion.py
    subversion/trunk/build/transform_sql.py
    subversion/trunk/gen-make.py
    subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c

Modified: subversion/trunk/build/generator/gen_base.py
URL: http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_base.py?rev=1661247&r1=1661246&r2=1661247&view=diff
==============================================================================
--- subversion/trunk/build/generator/gen_base.py (original)
+++ subversion/trunk/build/generator/gen_base.py Fri Feb 20 23:59:50 2015
@@ -240,12 +240,16 @@ class GeneratorBase:
         os.rename(new_hdrfile, hdrfile)
 
   def write_file_if_changed(self, fname, new_contents):
-    """Rewrite the file if new_contents are different than its current content.
+    """Rewrite the file if NEW_CONTENTS are different than its current content.
 
     If you have your windows projects open and generate the projects
     it's not a small thing for windows to re-read all projects so
     only update those that have changed.
+
+    Under Python >=3, NEW_CONTENTS must be a 'str', not a 'bytes'.
     """
+    if sys.version_info[0] >= 3:
+      new_contents = new_contents.encode()
 
     try:
       old_contents = open(fname, 'rb').read()

Modified: subversion/trunk/build/getversion.py
URL: http://svn.apache.org/viewvc/subversion/trunk/build/getversion.py?rev=1661247&r1=1661246&r2=1661247&view=diff
==============================================================================
--- subversion/trunk/build/getversion.py (original)
+++ subversion/trunk/build/getversion.py Fri Feb 20 23:59:50 2015
@@ -26,6 +26,7 @@
 import os
 import re
 import sys
+import traceback
 
 __all__ = ['Parser', 'Result']
 
@@ -64,8 +65,10 @@ def svn_extractor(parser, include_file):
 
   try:
     r = p.parse(include_file)
-  except IOError, e:
-    usage_and_exit(str(e))
+  except IOError:
+    typ, val, tb = sys.exc_info()
+    msg = ''.join(traceback.format_exception_only(typ, val))
+    usage_and_exit(msg)
   sys.stdout.write("%d.%d.%d" % (r.major, r.minor, r.patch))
 
 
@@ -75,8 +78,10 @@ def sqlite_extractor(parser, include_fil
 
   try:
     r = p.parse(include_file)
-  except IOError, e:
-    usage_and_exit(str(e))
+  except IOError:
+    typ, val, tb = sys.exc_info()
+    msg = ''.join(traceback.format_exception_only(typ, val))
+    usage_and_exit(msg)
   major = r.version / 1000000
   minor = (r.version - (major * 1000000)) / 1000
   micro = (r.version - (major * 1000000) - (minor * 1000))

Modified: subversion/trunk/build/transform_sql.py
URL: http://svn.apache.org/viewvc/subversion/trunk/build/transform_sql.py?rev=1661247&r1=1661246&r2=1661247&view=diff
==============================================================================
--- subversion/trunk/build/transform_sql.py (original)
+++ subversion/trunk/build/transform_sql.py Fri Feb 20 23:59:50 2015
@@ -194,14 +194,14 @@ class Processor(object):
             line)
 
       # Another preprocessing.
-      for symbol, string in self.token_map.iteritems():
+      for symbol, string in self.token_map.items():
         # ### This doesn't sql-escape 'string'
         line = re.sub(r'\b%s\b' % re.escape(symbol), "'%s'" % string, line)
 
       if line.strip():
         handled = False
 
-        for regex, handler in self._directives.iteritems():
+        for regex, handler in self._directives.items():
           match = regex.match(line)
           if match:
             handler(match)

Modified: subversion/trunk/gen-make.py
URL: http://svn.apache.org/viewvc/subversion/trunk/gen-make.py?rev=1661247&r1=1661246&r2=1661247&view=diff
==============================================================================
--- subversion/trunk/gen-make.py (original)
+++ subversion/trunk/gen-make.py Fri Feb 20 23:59:50 2015
@@ -25,7 +25,9 @@
 
 
 import os
+import traceback
 import sys
+
 import getopt
 try:
   my_getopt = getopt.gnu_getopt
@@ -266,8 +268,10 @@ if __name__ == '__main__':
                             ])
     if len(args) > 1:
       _usage_exit("Too many arguments")
-  except getopt.GetoptError, e:
-    _usage_exit(str(e))
+  except getopt.GetoptError:
+    typ, val, tb = sys.exc_info()
+    msg = ''.join(traceback.format_exception_only(typ, val))
+    _usage_exit(msg)
 
   conf = 'build.conf'
   skip = 0

Modified: subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c?rev=1661247&r1=1661246&r2=1661247&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c Fri Feb 20 23:59:50
2015
@@ -115,7 +115,7 @@ test_svn_subst_translate_string2_null_en
     svn_string_t *new_value = NULL;
     svn_boolean_t translated_to_utf8 = FALSE;
     svn_boolean_t translated_line_endings = TRUE;
-    /* 'Æ', which is 0xc6 in both ISO-8859-1 and Windows-1252 */
+    /* The 'AE' ligature, which is 0xc6 in both ISO-8859-1 and Windows-1252 */
     svn_string_t *source_string = svn_string_create("\xc6", pool);
 
     SVN_ERR(svn_subst_translate_string2(&new_value, &translated_to_utf8,



Mime
View raw message