Ticket #4244: setup3k.diff

File setup3k.diff, 4.5 KB (added by loewis, 7 years ago)
  • twisted/python/versions.py

     
    209209            formatFile = os.path.join(svn, 'format')
    210210            if os.path.exists(formatFile):
    211211                # It looks like a less-than-version-10 working copy.
    212                 format = file(formatFile).read().strip()
     212                format = open(formatFile).read().strip()
    213213                parser = getattr(self, '_parseSVNEntries_' + format, None)
    214214            else:
    215215                # It looks like a version-10-or-greater working copy, which
     
    220220                return 'Unknown'
    221221
    222222            entriesFile = os.path.join(svn, 'entries')
    223             entries = file(entriesFile)
     223            entries = open(entriesFile)
    224224            try:
    225225                try:
    226226                    return parser(entries)
  • twisted/python/dist.py

     
    1212from distutils import core
    1313from distutils.core import Extension
    1414
     15try:
     16    execfile
     17except NameError:
     18    from twisted.python.compat3k import execfile
     19
    1520twisted_subprojects = ["conch", "lore", "mail", "names",
    1621                       "news", "pair", "runner", "web", "web2",
    1722                       "words", "vfs"]
     
    277282        for f in os.listdir(self.build_dir):
    278283            fpath=os.path.join(self.build_dir, f)
    279284            if not fpath.endswith(".py"):
    280                 try:
     285                if os.path.exists(fpath + ".py"):
    281286                    os.unlink(fpath + ".py")
    282                 except EnvironmentError, e:
    283                     if e.args[1]=='No such file or directory':
    284                         pass
    285287                os.rename(fpath, fpath + ".py")
    286288
    287289
  • twisted/python/compat3k.py

     
     1def execfile(filename, *args):
     2    return exec(compile(open(filename).read(), filename, 'exec'), *args)
  • twisted/python/compat.py

    Eigenschaftsänderungen: twisted/python/compat3k.py
    ___________________________________________________________________
    Hinzugefügt: svn:keywords
       + Id
    Hinzugefügt: svn:eol-style
       + native
    
     
    135135                  'set_connect_state', 'set_accept_state',
    136136                  'connect_ex', 'sendall'):
    137137
    138             exec """def %s(self, *args):
     138            exec("""def %s(self, *args):
    139139                self._lock.acquire()
    140140                try:
    141141                    return apply(self._ssl_conn.%s, args)
    142142                finally:
    143                     self._lock.release()\n""" % (f, f)
     143                    self._lock.release()\n""" % (f, f))
    144144sys.modules['OpenSSL.tsafe'] = tsafe
    145145
    146146import operator
  • setup.py

     
    1515
    1616import sys, os
    1717
     18try:
     19    execfile
     20except NameError:
     21    from twisted.python.compat3k import execfile
    1822
    1923def getExtensions():
    2024    """
     
    8185        try:
    8286            list(parse_requirements(requirements))
    8387        except:
    84             print """You seem to be running a very old version of setuptools.
     88            print("""You seem to be running a very old version of setuptools.
    8589This version of setuptools has a bug parsing dependencies, so automatic
    8690dependency resolution is disabled.
    87 """
     91""")
    8892        else:
    8993            setup_args['install_requires'] = requirements
    9094        setup_args['include_package_data'] = True
    9195        setup_args['zip_safe'] = False
     96        if getattr(setuptools, '_distribute', False): # set to True in distribute
     97            setup_args['use_2to3'] = True
     98            if (3,1) <= sys.version_info < (3,2):
     99                # fix_callable chokes on twisted/trial/test/test_pyunitcompat.py
     100                # reported as http://bugs.python.org/issue7810
     101                from distutils.util import Mixin2to3
     102                import lib2to3.refactor
     103                Mixin2to3.fixer_names = lib2to3.refactor.get_fixers_from_package('lib2to3.fixes')
     104                Mixin2to3.fixer_names.remove('lib2to3.fixes.fix_callable')
    92105    setup(**setup_args)
    93106
    94107