Robert Brewer avatar Robert Brewer committed df1c92c

trunk sync with python3

Comments (0)

Files changed (11)

cherrypy/_cpwsgi_server.py

 from cherrypy import wsgiserver
 
 
-class CPHTTPRequest(wsgiserver.HTTPRequest):
-    pass
-
-
-class CPHTTPConnection(wsgiserver.HTTPConnection):
-    pass
-
-
 class CPWSGIServer(wsgiserver.CherryPyWSGIServer):
     """Wrapper for wsgiserver.CherryPyWSGIServer.
     

cherrypy/test/benchmark.py

         try:
             self.output = _cpmodpy.read_process(AB_PATH or "ab", self.args())
         except:
-            print _cperror.format_exc()
+            print(_cperror.format_exc())
             raise
         
         for attr, name, pattern in self.parse_patterns:
                 try:
                     run_standard_benchmarks()
                 except:
-                    print _cperror.format_exc()
+                    print(_cperror.format_exc())
                     raise
             finally:
                 cherrypy.engine.exit()

cherrypy/test/helper.py

             import testconfig
             _conf = testconfig.config.get('supervisor', None)
             if _conf is not None:
-                for k, v in _conf.iteritems():
+                for k, v in _conf.items():
                     if isinstance(v, basestring):
                         _conf[k] = unrepr(v)
                 conf.update(_conf)
     """Base class for modeling and controlling servers during testing."""
 
     def __init__(self, **kwargs):
-        for k, v in kwargs.iteritems():
+        for k, v in kwargs.items():
             if k == 'port':
                 setattr(self, k, int(v))
             setattr(self, k, v)
     using_wsgi = False
 
     def __init__(self, **kwargs):
-        for k, v in kwargs.iteritems():
+        for k, v in kwargs.items():
             setattr(self, k, v)
 
         cherrypy.server.httpserver = self.httpserver_class

cherrypy/test/test_core.py

             baseurl.exposed = True
         
         root = Root()
-        
-        
+                
+        if sys.version_info >= (2, 5):
+            from cherrypy.test.py25 import ExposeExamples
+            root.expose_dec = ExposeExamples()
+
+
         class TestType(type):
             """Metaclass which automatically exposes all functions in each subclass,
             and adds an instance of the subclass as an attribute of root.
                     cherrypy.response.cookie[str(name)] = cookie.value
 
 
-        if sys.version_info >= (2, 5):
-            from cherrypy.test import py25
-            Root.expose_dec = py25.ExposeExamples()
-        
         cherrypy.tree.mount(root)
 
 

cherrypy/test/test_etags.py

                       'tools.etags.autotags': True,
                       }}
         cherrypy.tree.mount(Root(), config=conf)
-
     
     def test_etags(self):
         self.getPage("/resource")

cherrypy/test/test_mime.py

             "--123456789--"])
         headers = [
             ('Content-Type', 'multipart/mixed; boundary=123456789'),
-            ('Content-Length', len(body)),
+            ('Content-Length', str(len(body))),
             ]
         self.getPage('/multipart', headers, "POST", body)
         self.assertBody(repr([text_part, html_part]))

cherrypy/test/test_refleaks.py

                     trash = {}
                     for x in gc.garbage:
                         trash[type(x)] = trash.get(type(x), 0) + 1
-                    trash = [(v, k) for k, v in trash.iteritems()]
+                    trash = [(v, k) for k, v in trash.items()]
                     trash.sort()
                     for pair in trash:
                         output.append("    " + repr(pair))

cherrypy/test/test_request_obj.py

             """
             def __init__(cls, name, bases, dct):
                 type.__init__(cls, name, bases, dct)
-                for value in dct.itervalues():
+                for value in dct.values():
                     if isinstance(value, types.FunctionType):
                         value.exposed = True
                 setattr(root, name.lower(), cls())
             }
         cherrypy.tree.mount(root, config=appconf)
 
- 
     def test_scheme(self):
         self.getPage("/scheme")
         self.assertBody(self.scheme)
     
     def testEmptyThreadlocals(self):
         results = []
-        for x in xrange(20):
+        for x in range(20):
             self.getPage("/threadlocal/")
             results.append(self.body)
         self.assertEqual(results, ["None"] * 20)

cherrypy/wsgiserver/__init__.py

 import threading
 import time
 import traceback
+def format_exc(limit=None):
+    """Like print_exc() but return a string. Backport for Python 2.3."""
+    try:
+        etype, value, tb = sys.exc_info()
+        return ''.join(traceback.format_exception(etype, value, tb, limit))
+    finally:
+        etype = value = tb = None
+
+
 from urllib import unquote
 from urlparse import urlparse
 import warnings
             pass
 
 
-def format_exc(limit=None):
-    """Like print_exc() but return a string. Backport for Python 2.3."""
-    try:
-        etype, value, tb = sys.exc_info()
-        return ''.join(traceback.format_exception(etype, value, tb, limit))
-    finally:
-        etype = value = tb = None
-
-
 _SHUTDOWNREQUEST = None
 
 class WorkerThread(threading.Thread):
                              "Use '0.0.0.0' (IPv4) or '::' (IPv6) instead "
                              "to listen on all active interfaces.")
         self._bind_addr = value
-        
     bind_addr = property(_get_bind_addr, _set_bind_addr,
         doc="""The interface on which to listen for connections.
         
     try:
         import setuptools
         if setuptools.__version__ == '0.0.1':
-            print >>sys.stderr, (
+            sys.stderr.write(
             "You have an obsolete version of setuptools installed.  Please\n"
             "remove it from your system entirely before rerunning this script."
             )
 
     except pkg_resources.VersionConflict:
         # XXX could we install in a subprocess here?
-        print >>sys.stderr, (
+        sys.stderr.write(
             "The required version of setuptools (>=%s) is not available, and\n"
             "can't be installed while this script is running. Please install\n"
             " a more recent version first."
     as an egg for download under the `download_base` URL (which should end
     with a '/'). `to_dir` is the directory where the egg will be downloaded.
     """
-    import urllib2, shutil
+    from urllib2 import urlopen
+    import shutil
     egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
     url = download_base + egg_name + '.zip'  # XXX
     saveto = os.path.join(to_dir, egg_name)
         try:
             from distutils import log
             log.warn("Downloading %s", url)
-            src = urllib2.urlopen(url)
+            src = urlopen(url)
             # Read/write all in one block, so we don't create a corrupt file
             # if the download is interrupted.
             data = src.read()
             from setuptools.command.easy_install import main
             main(argv)
         else:
-            print "Setuptools version",version,"or greater has been installed."
-            print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
+            print("Setuptools version",version,"or greater has been installed.")
+            print('(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)')
 if __name__=='__main__':
     main(sys.argv[1:])
 def main():
     if sys.version < required_python_version:
         s = "I'm sorry, but %s %s requires Python %s or later."
-        print s % (name, version, required_python_version)
+        print(s % (name, version, required_python_version))
         sys.exit(1)
     # set default location for "data_files" to
     # platform specific "site-packages" location
-    for scheme in INSTALL_SCHEMES.values():
+    for scheme in list(INSTALL_SCHEMES.values()):
         scheme['data'] = scheme['purelib']
     
     dist = setup(
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.