Commits

matt chisholm committed 5dff3b2 Draft

more fixes for Python 3

Comments (0)

Files changed (3)

setuptools/command/install_scripts.py

             f = open(target,"w"+mode)
             f.write(contents)
             f.close()
-            chmod(target,0755)
+            chmod(target,int('0755', 8))
 

setuptools/depends.py

             ptr += 3
 
             if op==EXTENDED_ARG:
-                extended_arg = arg * 65536L
+                extended_arg = arg * 65536
                 continue
 
         else:

setuptools/dist.py

 import setuptools, pkg_resources, distutils.core, distutils.dist, distutils.cmd
 import os, distutils.log
 
+try:
+    basestring
+except NameError:
+    basestring = type('') # Python3 support
+
 def _get_unpatched(cls):
     """Protect against re-patching the distutils if reloaded
 
     """Verify that entry_points map is parseable"""
     try:
         pkg_resources.EntryPoint.parse_map(value)
-    except ValueError, e:
+    except ValueError as e:
         raise DistutilsSetupError(e)
 
 def check_test_suite(dist, attr, value):
     """Verify that value is a dictionary of package names to glob lists"""
     if isinstance(value,dict):
         for k,v in value.items():
-            if not isinstance(k,str): break
+            if not isinstance(k,basestring): break
             try: iter(v)
             except TypeError:
                 break
             if not hasattr(self,ep.name):
                 setattr(self,ep.name,None)
         _Distribution.__init__(self,attrs)
-        if isinstance(self.metadata.version, (int,long,float)):
+        if isinstance(self.metadata.version, (int,float)):
             # Some people apparently take "version number" too literally :)
             self.metadata.version = str(self.metadata.version)
 
         self.standard = standard
         self.available = available
         self.optional = optional
-        if isinstance(require_features,(str,Require)):
+        if isinstance(require_features,(basestring,Require)):
             require_features = require_features,
 
         self.require_features = [
-            r for r in require_features if isinstance(r,str)
+            r for r in require_features if isinstance(r,basestring)
         ]
-        er = [r for r in require_features if not isinstance(r,str)]
+        er = [r for r in require_features if not isinstance(r,basestring)]
         if er: extras['require_features'] = er
 
-        if isinstance(remove,str):
+        if isinstance(remove,basestring):
             remove = remove,
         self.remove = remove
         self.extras = extras