SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V"
(b) V is now limited to a simple name (local variable)
(c) V is now deleted at the end of the except block
diff --git a/Lib/ctypes/macholib/dyld.py b/Lib/ctypes/macholib/dyld.py
index 376f65d..011a371 100644
--- a/Lib/ctypes/macholib/dyld.py
+++ b/Lib/ctypes/macholib/dyld.py
@@ -148,7 +148,7 @@
     """
     try:
         return dyld_find(fn, executable_path=executable_path, env=env)
-    except ValueError, e:
+    except ValueError as e:
         pass
     fmwk_index = fn.rfind('.framework')
     if fmwk_index == -1:
diff --git a/Lib/ctypes/test/__init__.py b/Lib/ctypes/test/__init__.py
index 2b745c2..245dda6 100644
--- a/Lib/ctypes/test/__init__.py
+++ b/Lib/ctypes/test/__init__.py
@@ -57,12 +57,12 @@
     for modname in find_package_modules(package, mask):
         try:
             mod = __import__(modname, globals(), locals(), ['*'])
-        except ResourceDenied, detail:
+        except ResourceDenied as detail:
             skipped.append(modname)
             if verbosity > 1:
                 print >> sys.stderr, "Skipped %s: %s" % (modname, detail)
             continue
-        except Exception, detail:
+        except Exception as detail:
             print >> sys.stderr, "Warning: could not import %s: %s" % (modname, detail)
             continue
         for name in dir(mod):
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py
index 2867cbf..c17ba3c 100644
--- a/Lib/ctypes/test/test_bitfields.py
+++ b/Lib/ctypes/test/test_bitfields.py
@@ -191,7 +191,7 @@
     def get_except(self, func, *args, **kw):
         try:
             func(*args, **kw)
-        except Exception, detail:
+        except Exception as detail:
             return detail.__class__, str(detail)
 
     def test_mixed_1(self):
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index 613163d..097e1da 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -313,7 +313,7 @@
     def get_except(self, func, *args):
         try:
             func(*args)
-        except Exception, detail:
+        except Exception as detail:
             return detail.__class__, str(detail)
 
 
@@ -388,7 +388,7 @@
 
         try:
             Recursive._fields_ = [("next", Recursive)]
-        except AttributeError, details:
+        except AttributeError as details:
             self.failUnless("Structure or union cannot contain itself" in
                             str(details))
         else:
@@ -405,7 +405,7 @@
 
         try:
             Second._fields_ = [("first", First)]
-        except AttributeError, details:
+        except AttributeError as details:
             self.failUnless("_fields_ is final" in
                             str(details))
         else:
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 2ee2968..e65646a 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -60,12 +60,12 @@
         finally:
             try:
                 os.unlink(outfile)
-            except OSError, e:
+            except OSError as e:
                 if e.errno != errno.ENOENT:
                     raise
             try:
                 os.unlink(ccout)
-            except OSError, e:
+            except OSError as e:
                 if e.errno != errno.ENOENT:
                     raise
         res = re.search(expr, trace)