Merged revisions 74672 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r74672 | ronald.oussoren | 2009-09-06 12:00:26 +0200 (Sun, 06 Sep 2009) | 1 line

  Fix build issues on OSX 10.6 (issue 6802)
........
diff --git a/Lib/plat-mac/aepack.py b/Lib/plat-mac/aepack.py
index 3b31b04..6021283 100644
--- a/Lib/plat-mac/aepack.py
+++ b/Lib/plat-mac/aepack.py
@@ -58,7 +58,11 @@
 # Some python types we need in the packer:
 #
 AEDescType = AE.AEDescType
-FSSType = Carbon.File.FSSpecType
+try:
+    FSSType = Carbon.File.FSSpecType
+except AttributeError:
+    class FSSType:
+        pass
 FSRefType = Carbon.File.FSRefType
 AliasType = Carbon.File.AliasType
 
diff --git a/Lib/plat-mac/applesingle.py b/Lib/plat-mac/applesingle.py
index f6c605f..13962f6 100644
--- a/Lib/plat-mac/applesingle.py
+++ b/Lib/plat-mac/applesingle.py
@@ -119,8 +119,13 @@
     if not hasattr(infile, 'read'):
         if isinstance(infile, Carbon.File.Alias):
             infile = infile.ResolveAlias()[0]
-        if isinstance(infile, (Carbon.File.FSSpec, Carbon.File.FSRef)):
-            infile = infile.as_pathname()
+
+        if hasattr(Carbon.File, "FSSpec"):
+            if isinstance(infile, (Carbon.File.FSSpec, Carbon.File.FSRef)):
+                infile = infile.as_pathname()
+        else:
+            if isinstance(infile, Carbon.File.FSRef):
+                infile = infile.as_pathname()
         infile = open(infile, 'rb')
 
     asfile = AppleSingle(infile, verbose=verbose)
diff --git a/Lib/plat-mac/buildtools.py b/Lib/plat-mac/buildtools.py
index 3480226..f137411 100644
--- a/Lib/plat-mac/buildtools.py
+++ b/Lib/plat-mac/buildtools.py
@@ -15,7 +15,10 @@
 import MacOS
 import macostools
 import macresource
-import EasyDialogs
+try:
+    import EasyDialogs
+except ImportError:
+    EasyDialogs = None
 import shutil
 
 
@@ -67,9 +70,13 @@
         rsrcname=None, others=[], raw=0, progress="default", destroot=""):
 
     if progress == "default":
-        progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120)
-        progress.label("Compiling...")
-        progress.inc(0)
+        if EasyDialogs is None:
+            print "Compiling %s"%(os.path.split(filename)[1],)
+            process = None
+        else:
+            progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120)
+            progress.label("Compiling...")
+            progress.inc(0)
     # check for the script name being longer than 32 chars. This may trigger a bug
     # on OSX that can destroy your sourcefile.
     if '#' in os.path.split(filename)[1]:
@@ -119,7 +126,11 @@
     if MacOS.runtimemodel == 'macho':
         raise BuildError, "No updating yet for MachO applets"
     if progress:
-        progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120)
+        if EasyDialogs is None:
+            print "Updating %s"%(os.path.split(filename)[1],)
+            progress = None
+        else:
+            progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120)
     else:
         progress = None
     if not output:
diff --git a/Lib/plat-mac/macresource.py b/Lib/plat-mac/macresource.py
index f02453b..52e3e89 100644
--- a/Lib/plat-mac/macresource.py
+++ b/Lib/plat-mac/macresource.py
@@ -79,8 +79,8 @@
     AppleSingle file"""
     try:
         refno = Res.FSpOpenResFile(pathname, 1)
-    except Res.Error, arg:
-        if arg[0] in (-37, -39):
+    except (AttributeError, Res.Error), arg:
+        if isinstance(arg, AttributeError) or arg[0] in (-37, -39):
             # No resource fork. We may be on OSX, and this may be either
             # a data-fork based resource file or a AppleSingle file
             # from the CVS repository.
@@ -106,8 +106,8 @@
     try:
         refno = Res.FSpOpenResFile(pathname, 1)
         Res.CloseResFile(refno)
-    except Res.Error, arg:
-        if arg[0] in (-37, -39):
+    except (AttributeError, Res.Error), arg:
+        if instance(arg, AttributeError), or arg[0] in (-37, -39):
             # No resource fork. We may be on OSX, and this may be either
             # a data-fork based resource file or a AppleSingle file
             # from the CVS repository.
diff --git a/Lib/test/test_aepack.py b/Lib/test/test_aepack.py
index 8a4b035..c44f1ef 100755
--- a/Lib/test/test_aepack.py
+++ b/Lib/test/test_aepack.py
@@ -59,6 +59,9 @@
             import Carbon.File
         except:
             return
+
+        if not hasattr(Carbon.File, "FSSpec"):
+            return
         o = Carbon.File.FSSpec(os.curdir)
         packed = aepack.pack(o)
         unpacked = aepack.unpack(packed)
@@ -69,6 +72,8 @@
             import Carbon.File
         except:
             return
+        if not hasattr(Carbon.File, "FSSpec"):
+            return
         o = Carbon.File.FSSpec(os.curdir).NewAliasMinimal()
         packed = aepack.pack(o)
         unpacked = aepack.unpack(packed)