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/distutils/dir_util.py b/Lib/distutils/dir_util.py
index 92f4934..398f242 100644
--- a/Lib/distutils/dir_util.py
+++ b/Lib/distutils/dir_util.py
@@ -75,7 +75,7 @@
             try:
                 os.mkdir(head)
                 created_dirs.append(head)
-            except OSError, exc:
+            except OSError as exc:
                 raise DistutilsFileError, \
                       "could not create '%s': %s" % (head, exc[-1])
 
@@ -142,7 +142,8 @@
               "cannot copy tree '%s': not a directory" % src
     try:
         names = os.listdir(src)
-    except os.error, (errno, errstr):
+    except os.error as e:
+        (errno, errstr) = e
         if dry_run:
             names = []
         else:
@@ -209,7 +210,7 @@
             abspath = os.path.abspath(cmd[1])
             if abspath in _path_created:
                 del _path_created[abspath]
-        except (IOError, OSError), exc:
+        except (IOError, OSError) as exc:
             log.warn(grok_environment_error(
                     exc, "error removing %s: " % directory))