Howdy,

So
http://docs.python.org/release/3.0.1/whatsnew/3.0.html#porting-to-python-3-0

specifically says not to try to
if 2.x
 stuff
else 3.x
 other stuff
fi

Attached is a diff for gen-build.py using 2to3. I'm not exactly sure how
to fanagle this without duplicating the into 2 files gen-build2.py and
gen-build3.py.  configure.in would need to me modded to call the right
one based on the python version.

I'm looking at this specifically b/c
http://www.freebsd.org/cgi/query-pr.cgi?pr=146621&cat=

Also you need this diff to build/buildcheck.sh
$ svn diff
Index: buildcheck.sh
===================================================================
--- buildcheck.sh       (revision 946860)
+++ buildcheck.sh       (working copy)
@@ -10,7 +10,7 @@
 echo "           to build APR from SVN."
 exit 1
 else
-py_version=`python -c 'import sys; print sys.version' 2>&1|sed 's/ .*//;q'`
+py_version=`python -c 'import sys; print(sys.version)' 2>&1|sed 's/
.*//;q'`
 echo "buildconf: python version $py_version (ok)"
 fi





-- 
------------------------------------------------------------------------
Philip M. Gollucci ([email protected])
p: 703.549.2050x206, did: 703.579.6947
Senior System Admin - RideCharge, Inc.  http://ridecharge.com
1024D/DB9B8C1C B90B FBC3 A3A1 C71A 8E70  3F8C 75B8 8FFB DB9B 8C1C

Work like you don't need the money,
love like you'll never get hurt,
and dance like nobody's watching.
--- gen-build.py (original)
+++ gen-build.py (refactored)
@@ -10,7 +10,7 @@
 
 
 import os
-import ConfigParser
+import configparser
 import getopt
 import string
 import glob
@@ -36,7 +36,7 @@
 
 
 def main():
-  parser = ConfigParser.ConfigParser()
+  parser = configparser.ConfigParser()
   parser.read('build.conf')
 
   if parser.has_option('options', 'dsp'):
@@ -86,7 +86,7 @@
           inherit_files[-1] = inherit_files[-1][:-2] + '.lo'
           # replace the \\'s with /'s
           inherit_line = '/'.join(inherit_files)
-          if not inherit_parent.has_key(inherit_files[0]):
+          if inherit_files[0] not in inherit_parent:
             inherit_parent[inherit_files[0]] = []
           inherit_parent[inherit_files[0]].append(inherit_line)
 
@@ -106,7 +106,7 @@
       files = get_files(path + '/*.c')
       objects, _unused = write_objects(f, legal_deps, h_deps, files)
 
-      if inherit_parent.has_key(subdir):
+      if subdir in inherit_parent:
         objects = objects + inherit_parent[subdir]
 
       symname = 'OBJECTS_%s_%s' % (subdir, platform)
@@ -125,7 +125,7 @@
     f.write('OBJECTS_%s = %s\n\n' % (platform, string.join(group)))
 
   f.write('HEADERS = $(top_srcdir)/%s\n\n' % string.join(headers, ' 
$(top_srcdir)/'))
-  f.write('SOURCE_DIRS = %s $(EXTRA_SOURCE_DIRS)\n\n' % 
string.join(dirs.keys()))
+  f.write('SOURCE_DIRS = %s $(EXTRA_SOURCE_DIRS)\n\n' % 
string.join(list(dirs.keys())))
 
   if parser.has_option('options', 'modules'):
     modules = parser.get('options', 'modules')
@@ -146,14 +146,14 @@
 
   # Build a list of all necessary directories in build tree
   alldirs = { }
-  for dir in dirs.keys():
+  for dir in list(dirs.keys()):
     d = dir
     while d:
       alldirs[d] = None
       d = os.path.dirname(d)
 
   # Sort so 'foo' is before 'foo/bar'
-  keys = alldirs.keys()
+  keys = list(alldirs.keys())
   keys.sort()
   f.write('BUILD_DIRS = %s\n\n' % string.join(keys))
 
@@ -177,10 +177,10 @@
 
     # what headers does this file include, along with the implied headers
     deps = extract_deps(file, legal_deps)
-    for hdr in deps.keys():
+    for hdr in list(deps.keys()):
       deps.update(h_deps.get(hdr, {}))
 
-    vals = deps.values()
+    vals = list(deps.values())
     vals.sort()
     f.write('%s: %s .make.dirs %s\n' % (obj, file, string.join(vals)))
 
@@ -196,7 +196,7 @@
     if line[:8] != '#include':
       continue
     inc = _re_include.match(line).group(1)
-    if inc in legal_deps.keys():
+    if inc in list(legal_deps.keys()):
       deps[inc] = legal_deps[inc]
   return deps
 _re_include = re.compile('#include *["<](.*)[">]')
@@ -207,10 +207,10 @@
   altered = 1
   while altered:
     altered = 0
-    for hdr, deps in header_deps.items():
+    for hdr, deps in list(header_deps.items()):
       # print hdr, deps
       start = len(deps)
-      for dep in deps.keys():
+      for dep in list(deps.keys()):
         deps.update(header_deps.get(dep, {}))
       if len(deps) != start:
         altered = 1
@@ -221,7 +221,7 @@
 def get_files(patterns):
   files = [ ]
   for pat in string.split(patterns):
-    files.extend(map(clean_path, glob.glob(pat)))
+    files.extend(list(map(clean_path, glob.glob(pat))))
   files.sort()
   return files
 

Reply via email to