Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 2029

Show
Ignore:
Timestamp:
07/25/08 12:16:43
Author:
fumanchu
Message:

First wave of py3k conversions. Looks like we need to reimplement nonblocking makefile again--the whole socket api changed. :(

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/py3k/cherrypy/__init__.py

    r2007 r2029  
    6060__version__ = "3.1.0" 
    6161 
    62 from urlparse import urljoin as _urljoin 
     62from urllib.parse import urljoin as _urljoin 
    6363 
    6464 
     
    9494            Help on class Thing in module pkg.mod: 
    9595             
    96             class Thing(__builtin__.object) 
     96            class Thing(builtins.object) 
    9797             |  A thing and its properties. 
    9898             |   
     
    127127        newdoc = [cls.__doc__ or ""] 
    128128         
    129         dctnames = dct.keys() 
    130         dctnames.sort() 
    131          
    132         for name in dctnames: 
     129        for name in sorted(dct.keys()): 
    133130            if name.endswith("__doc"): 
    134131                # Remove the magic doc attribute. 
     
    407404        func.exposed = True 
    408405        if alias is not None: 
    409             if isinstance(alias, basestring): 
     406            if isinstance(alias, (str, bytes)): 
    410407                parents[alias.replace(".", "_")] = func 
    411408            else: 
  • branches/py3k/cherrypy/_cpcgifs.py

    r762 r2029  
    77        try: 
    88            cgi.FieldStorage.__init__(self, *args, **kwds) 
    9         except ValueError, ex: 
     9        except ValueError as ex: 
    1010            if str(ex) == 'Maximum content length exceeded': 
    1111                raise cherrypy.HTTPError(status=413) 
  • branches/py3k/cherrypy/_cpchecker.py

    r1841 r2029  
    4848     
    4949    def check_skipped_app_config(self): 
    50         for sn, app in cherrypy.tree.apps.iteritems(): 
     50        for sn, app in cherrypy.tree.apps.items(): 
    5151            if not isinstance(app, cherrypy.Application): 
    5252                continue 
     
    6565        # Use the dummy Request object in the main thread. 
    6666        request = cherrypy.request 
    67         for sn, app in cherrypy.tree.apps.iteritems(): 
     67        for sn, app in cherrypy.tree.apps.items(): 
    6868            if not isinstance(app, cherrypy.Application): 
    6969                continue 
     
    131131    def _compat(self, config): 
    132132        """Process config and warn on each obsolete or deprecated entry.""" 
    133         for section, conf in config.iteritems(): 
     133        for section, conf in config.items(): 
    134134            if isinstance(conf, dict): 
    135                 for k, v in conf.iteritems(): 
     135                for k, v in conf.items(): 
    136136                    if k in self.obsolete: 
    137137                        warnings.warn("%r is obsolete. Use %r instead.\n" 
     
    153153        """Process config and warn on each obsolete or deprecated entry.""" 
    154154        self._compat(cherrypy.config) 
    155         for sn, app in cherrypy.tree.apps.iteritems(): 
     155        for sn, app in cherrypy.tree.apps.items(): 
    156156            if not isinstance(app, cherrypy.Application): 
    157157                continue 
     
    171171        ns += self.extra_config_namespaces 
    172172         
    173         for section, conf in app.config.iteritems(): 
     173        for section, conf in app.config.items(): 
    174174            is_path_section = section.startswith("/") 
    175175            if is_path_section and isinstance(conf, dict): 
    176                 for k, v in conf.iteritems(): 
     176                for k, v in conf.items(): 
    177177                    atoms = k.split(".") 
    178178                    if len(atoms) > 1: 
     
    198198    def check_config_namespaces(self): 
    199199        """Process config and warn on each unknown config namespace.""" 
    200         for sn, app in cherrypy.tree.apps.iteritems(): 
     200        for sn, app in cherrypy.tree.apps.items(): 
    201201            if not isinstance(app, cherrypy.Application): 
    202202                continue 
     
    211211     
    212212    def _populate_known_types(self): 
    213         import __builtin__ 
    214         builtins = [x for x in vars(__builtin__).values() 
     213        import builtins 
     214        builtins = [x for x in vars(builtins).values() 
    215215                    if type(x) is type(str)] 
    216216         
     
    231231               "which does not match the expected type %r.") 
    232232         
    233         for section, conf in config.iteritems(): 
     233        for section, conf in config.items(): 
    234234            if isinstance(conf, dict): 
    235                 for k, v in conf.iteritems(): 
     235                for k, v in conf.items(): 
    236236                    if v is not None: 
    237237                        expected_type = self.known_config_types.get(k, None) 
     
    252252        """Assert that config values are of the same type as default values.""" 
    253253        self._known_types(cherrypy.config) 
    254         for sn, app in cherrypy.tree.apps.iteritems(): 
     254        for sn, app in cherrypy.tree.apps.items(): 
    255255            if not isinstance(app, cherrypy.Application): 
    256256                continue 
     
    262262    def check_localhost(self): 
    263263        """Warn if any socket_host is 'localhost'. See #711.""" 
    264         for k, v in cherrypy.config.iteritems(): 
     264        for k, v in cherrypy.config.items(): 
    265265            if k == 'server.socket_host' and v == 'localhost': 
    266266                warnings.warn("The use of 'localhost' as a socket host can " 
  • branches/py3k/cherrypy/_cpconfig.py

    r1989 r2029  
    9494""" 
    9595 
    96 import ConfigParser 
     96import configparser 
    9797try: 
    9898    set 
     
    139139def as_dict(config): 
    140140    """Return a dict from 'config' whether it is a dict, file, or filename.""" 
    141     if isinstance(config, basestring): 
     141    if isinstance(config, (str, bytes)): 
    142142        config = _Parser().dict_from_file(config) 
    143143    elif hasattr(config, 'read'): 
     
    151151    the list of files to monitor for "autoreload" changes. 
    152152    """ 
    153     if isinstance(other, basestring): 
     153    if isinstance(other, (str, bytes)): 
    154154        cherrypy.engine.autoreload.files.add(other) 
    155155     
    156156    # Load other into base 
    157     for section, value_map in as_dict(other).iteritems(): 
     157    for section, value_map in as_dict(other).items(): 
    158158        base.setdefault(section, {}).update(value_map) 
    159159 
     
    193193        # I chose __enter__ and __exit__ so someday this could be 
    194194        # rewritten using Python 2.5's 'with' statement: 
    195         # for ns, handler in self.iteritems(): 
     195        # for ns, handler in self.items(): 
    196196        #     with handler as callable: 
    197         #         for k, v in ns_confs.get(ns, {}).iteritems(): 
     197        #         for k, v in ns_confs.get(ns, {}).items(): 
    198198        #             callable(k, v) 
    199         for ns, handler in self.iteritems(): 
     199        for ns, handler in self.items(): 
    200200            exit = getattr(handler, "__exit__", None) 
    201201            if exit: 
     
    204204                try: 
    205205                    try: 
    206                         for k, v in ns_confs.get(ns, {}).iteritems(): 
     206                        for k, v in ns_confs.get(ns, {}).items(): 
    207207                            callable(k, v) 
    208208                    except: 
     
    219219                        exit(None, None, None) 
    220220            else: 
    221                 for k, v in ns_confs.get(ns, {}).iteritems(): 
     221                for k, v in ns_confs.get(ns, {}).items(): 
    222222                    handler(k, v) 
    223223     
     
    258258    def update(self, config): 
    259259        """Update self from a dict, file or filename.""" 
    260         if isinstance(config, basestring): 
     260        if isinstance(config, (str, bytes)): 
    261261            # Filename 
    262262            cherrypy.engine.autoreload.files.add(config) 
     
    321321 
    322322 
    323 class _Parser(ConfigParser.ConfigParser): 
     323class _Parser(configparser.ConfigParser): 
    324324    """Sub-class of ConfigParser that keeps the case of options and that raises 
    325325    an exception if the file cannot be read. 
     
    330330     
    331331    def read(self, filenames): 
    332         if isinstance(filenames, basestring): 
     332        if isinstance(filenames, (str, bytes)): 
    333333            filenames = [filenames] 
    334334        for filename in filenames: 
     
    355355                try: 
    356356                    value = unrepr(value) 
    357                 except Exception, x: 
     357                except Exception as x: 
    358358                    msg = ("Config error in section: %r, option: %r, " 
    359359                           "value: %r. Config values must be valid Python." % 
     
    370370        return self.as_dict() 
    371371 
    372 del ConfigParser 
     372del configparser 
  • branches/py3k/cherrypy/_cperror.py

    r1949 r2029  
    44from sys import exc_info as _exc_info 
    55from traceback import format_exception as _format_exception 
    6 from urlparse import urljoin as _urljoin 
     6from urllib.parse import urljoin as _urljoin 
    77from cherrypy.lib import http as _http 
    88 
     
    5858        request = cherrypy.request 
    5959         
    60         if isinstance(urls, basestring): 
     60        if isinstance(urls, (str, bytes)): 
    6161            urls = [urls] 
    6262         
     
    276276    try: 
    277277        code, reason, message = _http.valid_status(status) 
    278     except ValueError, x: 
     278    except ValueError as x: 
    279279        raise cherrypy.HTTPError(500, x.args[0]) 
    280280     
     
    290290        kwargs['version'] = cherrypy.__version__ 
    291291     
    292     for k, v in kwargs.iteritems(): 
     292    for k, v in kwargs.items(): 
    293293        if v is None: 
    294294            kwargs[k] = "" 
  • branches/py3k/cherrypy/_cplogging.py

    r1984 r2029  
    77logfmt = logging.Formatter("%(message)s") 
    88import os 
    9 import rfc822 
     9from email._parseaddr import _monthnames 
    1010import sys 
    1111 
     
    8989                 'a': inheaders.get('User-Agent', ''), 
    9090                 } 
    91         for k, v in atoms.items(): 
     91        for k, v in list(atoms.items()): 
    9292            if isinstance(v, unicode): 
    9393                v = v.encode('utf8') 
     
    108108        """Return now() in Apache Common Log Format (no timezone).""" 
    109109        now = datetime.datetime.now() 
    110         month = rfc822._monthnames[now.month - 1].capitalize() 
     110        month = _monthnames[now.month - 1].capitalize() 
    111111        return ('[%02d/%s/%04d:%02d:%02d:%02d]' % 
    112112                (now.day, month, now.year, now.hour, now.minute, now.second)) 
  • branches/py3k/cherrypy/_cpmodpy.py

    r1989 r2029  
    5757 
    5858import logging 
    59 import StringIO 
     59import io 
    6060 
    6161import cherrypy 
     
    184184            qs = req.args or "" 
    185185            reqproto = req.protocol 
    186             headers = req.headers_in.items(
     186            headers = list(req.headers_in.items()
    187187            rfile = _ReadOnlyRequest(req) 
    188188            prev = None 
     
    203203                        request.run(method, path, qs, reqproto, headers, rfile) 
    204204                        break 
    205                     except cherrypy.InternalRedirect, ir: 
     205                    except cherrypy.InternalRedirect as ir: 
    206206                        app.release_serving() 
    207207                        prev = request 
     
    221221                        path = ir.path 
    222222                        qs = ir.query_string 
    223                         rfile = StringIO.StringIO() 
     223                        rfile = io.StringIO() 
    224224                 
    225225                send_response(req, response.status, response.header_list, 
     
    252252     
    253253    # Set response body 
    254     if isinstance(body, basestring): 
     254    if isinstance(body, (str, bytes)): 
    255255        req.write(body) 
    256256    else: 
  • branches/py3k/cherrypy/_cprequest.py

    r1994 r2029  
    11 
    2 import Cookie 
     2from http import cookies 
    33import os 
    44import sys 
     
    6464                   self.failsafe, self.priority, 
    6565                   ", ".join(['%s=%r' % (k, v) 
    66                               for k, v in self.kwargs.iteritems()]))) 
     66                              for k, v in self.kwargs.items()]))) 
    6767 
    6868 
     
    112112        # We can't just use 'update' because we want copies of the 
    113113        # mutable values (each is a list) as well. 
    114         for k, v in self.iteritems(): 
     114        for k, v in self.items(): 
    115115            newmap[k] = v[:] 
    116116        return newmap 
     
    130130    # Little-known fact you only get from reading source ;) 
    131131    hookpoint = k.split(".", 1)[0] 
    132     if isinstance(v, basestring): 
     132    if isinstance(v, (str, bytes)): 
    133133        v = cherrypy.lib.attributes(v) 
    134134    if not isinstance(v, Hook): 
     
    252252    http.HeaderMap, http.HeaderElement.""" 
    253253     
    254     cookie = Cookie.SimpleCookie() 
    255     cookie__doc = """See help(Cookie).""" 
     254    cookie = cookies.SimpleCookie() 
     255    cookie__doc = """See help(http.cookies).""" 
    256256     
    257257    rfile = None 
     
    530530            self.rfile = rfile 
    531531            self.headers = http.HeaderMap() 
    532             self.cookie = Cookie.SimpleCookie() 
     532            self.cookie = cookies.SimpleCookie() 
    533533            self.handler = None 
    534534             
     
    609609                    self.hooks.run('before_finalize') 
    610610                    cherrypy.response.finalize() 
    611                 except (cherrypy.HTTPRedirect, cherrypy.HTTPError), inst: 
     611                except (cherrypy.HTTPRedirect, cherrypy.HTTPError) as inst: 
    612612                    inst.set_response() 
    613613                    self.stage = 'before_finalize (HTTPError)' 
     
    706706        # didn't provide a "Content-Type" header. 
    707707        if 'Content-Type' not in self.headers: 
    708             h = http.HeaderMap(self.headers.items()) 
     708            h = http.HeaderMap(list(self.headers.items())) 
    709709            h['Content-Type'] = '' 
    710710        else: 
     
    717717                                          environ={'REQUEST_METHOD': "POST"}, 
    718718                                          keep_blank_values=1) 
    719         except Exception, e: 
     719        except Exception as e: 
    720720            if e.__class__.__name__ == 'MaxSizeExceeded': 
    721721                # Post data is too big 
     
    743743            self.hooks.run("after_error_response") 
    744744            cherrypy.response.finalize() 
    745         except cherrypy.HTTPRedirect, inst: 
     745        except cherrypy.HTTPRedirect as inst: 
    746746            inst.set_response() 
    747747            cherrypy.response.finalize() 
     
    769769    def __set__(self, obj, value): 
    770770        # Convert the given value to an iterable object. 
    771         if isinstance(value, basestring): 
     771        if isinstance(value, (str, bytes)): 
    772772            # strings get wrapped in a list because iterating over a single 
    773773            # item list is much faster than iterating over every character 
     
    814814    http.HeaderMap, http.HeaderElement.""" 
    815815     
    816     cookie = Cookie.SimpleCookie() 
    817     cookie__doc = """See help(Cookie).""" 
     816    cookie = cookies.SimpleCookie() 
     817    cookie__doc = """See help(http.cookies).""" 
    818818     
    819819    body = Body() 
     
    848848            "Date": http.HTTPDate(self.time), 
    849849        }) 
    850         self.cookie = Cookie.SimpleCookie() 
     850        self.cookie = cookies.SimpleCookie() 
    851851     
    852852    def collapse_body(self): 
     
    860860        try: 
    861861            code, reason, _ = http.valid_status(self.status) 
    862         except ValueError, x: 
     862        except ValueError as x: 
    863863            raise cherrypy.HTTPError(500, x.args[0]) 
    864864         
  • branches/py3k/cherrypy/_cpserver.py

    r1994 r2029  
    7373            from cherrypy import _cpwsgi_server 
    7474            httpserver = _cpwsgi_server.CPWSGIServer() 
    75         if isinstance(httpserver, basestring): 
     75        if isinstance(httpserver, (str, bytes)): 
    7676            httpserver = attributes(httpserver)() 
    7777         
  • branches/py3k/cherrypy/_cptools.py

    r2013 r2029  
    3232    if isinstance(func, types.MethodType): 
    3333        func = func.im_func 
    34     co = func.func_code 
     34    co = func.__code__ 
    3535    return co.co_varnames[:co.co_argcount] 
    3636 
     
    106106            subspace = self.namespace + "." + self._name + "." 
    107107            f._cp_config[subspace + "on"] = True 
    108             for k, v in kwargs.iteritems(): 
     108            for k, v in kwargs.items(): 
    109109                f._cp_config[subspace + k] = v 
    110110            return f 
     
    287287         
    288288        # Grab cookie-relevant tool args 
    289         conf = dict([(k, v) for k, v in self._merged_args().iteritems() 
     289        conf = dict([(k, v) for k, v in self._merged_args().items() 
    290290                     if k in ('path', 'path_header', 'name', 'timeout', 
    291291                              'domain', 'secure')]) 
     
    347347            # raising an exception here will do that; see 
    348348            # cherrypy.lib.xmlrpc.on_error 
    349             raise Exception, 'method "%s" is not supported' % attr 
     349            raise Exception('method "%s" is not supported' % attr) 
    350350         
    351351        conf = cherrypy.request.toolmaps['tools'].get("xmlrpc", {}) 
     
    400400             
    401401            # Take all remaining kwargs and set them on the Cache object. 
    402             for k, v in kwargs.iteritems(): 
     402            for k, v in kwargs.items(): 
    403403                setattr(cherrypy._cache, k, v) 
    404404         
  • branches/py3k/cherrypy/_cptree.py

    r1989 r2029  
    104104        req.app = self 
    105105         
    106         for name, toolbox in self.toolboxes.iteritems(): 
     106        for name, toolbox in self.toolboxes.items(): 
    107107            req.namespaces[name] = toolbox 
    108108         
  • branches/py3k/cherrypy/_cpwsgi.py

    r1994 r2029  
    11"""WSGI interface (see PEP 333).""" 
    22 
    3 import StringIO as _StringIO 
     3import io as _io 
    44import sys as _sys 
    55 
     
    8383            self.close() 
    8484            raise 
    85         except _cherrypy.InternalRedirect, ir: 
     85        except _cherrypy.InternalRedirect as ir: 
    8686            self.environ['cherrypy.previous_request'] = _cherrypy.serving.request 
    8787            self.close() 
     
    151151        env['PATH_INFO'] = path 
    152152        env['QUERY_STRING'] = query_string 
    153         env['wsgi.input'] = _StringIO.StringIO() 
     153        env['wsgi.input'] = _io.StringIO() 
    154154        env['CONTENT_LENGTH'] = "0" 
    155155         
     
    171171            self.close() 
    172172            raise 
    173         except _cherrypy.InternalRedirect, ir: 
     173        except _cherrypy.InternalRedirect as ir: 
    174174            self.environ['cherrypy.previous_request'] = _cherrypy.serving.request 
    175175            self.close() 
  • branches/py3k/cherrypy/lib/__init__.py

    r1794 r2029  
    1919     
    2020    # Parse out the path, module, and attribute 
    21     last_dot = full_attribute_name.rfind(u".") 
     21    last_dot = full_attribute_name.rfind(".") 
    2222    attr_name = full_attribute_name[last_dot + 1:] 
    2323    mod_path = full_attribute_name[:last_dot] 
     
    9090            pass 
    9191         
    92         # See if the Name is in __builtin__
     92        # See if the Name is in builtins
    9393        try: 
    94             import __builtin__ 
    95             return getattr(__builtin__, o.name) 
     94            import builtins 
     95            return getattr(builtins, o.name) 
    9696        except AttributeError: 
    9797            pass 
  • branches/py3k/cherrypy/lib/auth.py

    r1931 r2029  
    2020 
    2121                if not isinstance(users, dict): 
    22                     raise ValueError, "Authentication users must be a dictionary" 
     22                    raise ValueError("Authentication users must be a dictionary") 
    2323                 
    2424                # fetch the user password 
     
    2929        else: 
    3030            if not isinstance(users, dict): 
    31                 raise ValueError, "Authentication users must be a dictionary" 
     31                raise ValueError("Authentication users must be a dictionary") 
    3232             
    3333            # fetch the user password 
  • branches/py3k/cherrypy/lib/caching.py

    r1798 r2029  
    4242        while time: 
    4343            now = time.time() 
    44             for expiration_time, objects in self.expirations.items(): 
     44            for expiration_time, objects in list(self.expirations.items()): 
    4545                if expiration_time <= now: 
    4646                    for obj_size, obj_key in objects: 
     
    158158            # resurrected just above (response.headers = cache_data[1]). 
    159159            cptools.validate_since() 
    160         except cherrypy.HTTPRedirect, x: 
     160        except cherrypy.HTTPRedirect as x: 
    161161            if x.status == 304: 
    162162                cherrypy._cache.tot_non_modified += 1 
     
    185185            if vary: 
    186186                sel_headers = dict([(k, v) for k, v 
    187                                     in cherrypy.request.headers.iteritems() 
     187                                    in cherrypy.request.headers.items() 
    188188                                    if k in vary]) 
    189189            else: 
  • branches/py3k/cherrypy/lib/covercp.py

    r1814 r2029  
    2626localFile = os.path.join(os.path.dirname(__file__), "coverage.cache") 
    2727 
    28 try: 
    29     import cStringIO as StringIO 
    30 except ImportError: 
    31     import StringIO 
    3228 
    3329try: 
     
    191187     
    192188    # Show the directory name and any of our children 
    193     dirs = [k for k, v in root.iteritems() if v] 
     189    dirs = [k for k, v in root.items() if v] 
    194190    dirs.sort() 
    195191    for name in dirs: 
     
    208204    if path.lower().startswith(base): 
    209205        relpath = path[len(base):] 
    210         files = [k for k, v in root.iteritems() if not v] 
     206        files = [k for k, v in root.items() if not v] 
    211207        files.sort() 
    212208        for name in files: 
  • branches/py3k/cherrypy/lib/cptools.py

    r2016 r2029  
    22 
    33import logging 
    4 import md5 
     4from hashlib import md5 
    55import re 
    66 
     
    4141        if status == 200: 
    4242            etag = response.collapse_body() 
    43             etag = '"%s"' % md5.new(etag).hexdigest() 
     43            etag = '"%s"' % md5(etag).hexdigest() 
    4444            response.headers['ETag'] = etag 
    4545     
     
    282282def session_auth(**kwargs): 
    283283    sa = SessionAuth() 
    284     for k, v in kwargs.iteritems(): 
     284    for k, v in kwargs.items(): 
    285285        setattr(sa, k, v) 
    286286    return sa.run() 
     
    390390    if not media: 
    391391        return 
    392     if isinstance(media, basestring): 
     392    if isinstance(media, (str, bytes)): 
    393393        media = [media] 
    394394     
  • branches/py3k/cherrypy/lib/encoding.py

    r1993 r2029  
    106106            # Encoded strings may be of different lengths from their 
    107107            # unicode equivalents, and even from each other. For example: 
    108             # >>> t = u"\u7007\u3040" 
     108            # >>> t = "\u7007\u3040" 
    109109            # >>> len(t) 
    110110            # 2 
     
    195195    yield zobj.flush() 
    196196    yield struct.pack("<l", crc) 
    197     yield struct.pack("<L", size & 0xFFFFFFFFL
     197    yield struct.pack("<L", size & 0xFFFFFFFF
    198198 
    199199def decompress(body): 
    200     import gzip, StringIO 
    201      
    202     zbuf = StringIO.StringIO() 
     200    import gzip, io 
     201     
     202    zbuf = io.StringIO() 
    203203    zbuf.write(body) 
    204204    zbuf.seek(0) 
  • branches/py3k/cherrypy/lib/http.py

    r2026 r2029  
    77# to a public caning. 
    88 
    9 from BaseHTTPServer import BaseHTTPRequestHandler 
     9from http.server import BaseHTTPRequestHandler 
    1010response_codes = BaseHTTPRequestHandler.responses.copy() 
    1111 
     
    2222import cgi 
    2323import re 
    24 from rfc822 import formatdate as HTTPDate 
     24from email.utils import formatdate as HTTPDate 
    2525 
    2626 
     
    102102     
    103103    def __unicode__(self): 
    104         p = [";%s=%s" % (k, v) for k, v in self.params.iteritems()] 
    105         return u"%s%s" % (self.value, "".join(p)) 
     104        p = [";%s=%s" % (k, v) for k, v in self.params.items()] 
     105        return "%s%s" % (self.value, "".join(p)) 
    106106     
    107107    def __str__(self): 
     
    195195 
    196196def decode_TEXT(value): 
    197     """Decode RFC-2047 TEXT (e.g. "=?utf-8?q?f=C3=BCr?=" -> u"f\xfcr").""" 
     197    """Decode RFC-2047 TEXT (e.g. "=?utf-8?q?f=C3=BCr?=" -> "f\xfcr").""" 
    198198    from email.Header import decode_header 
    199199    atoms = decode_header(value) 
     
    265265    else: 
    266266        pm = cgi.parse_qs(query_string, keep_blank_values) 
    267         for key, val in pm.items(): 
     267        for key, val in list(pm.items()): 
    268268            if len(val) == 1: 
    269269                pm[key] = val[0] 
     
    358358        """Transform self into a list of (name, value) tuples.""" 
    359359        header_list = [] 
    360         for key, v in self.iteritems(): 
     360        for key, v in self.items(): 
    361361            if isinstance(v, unicode): 
    362362                # HTTP/1.0 says, "Words of *TEXT may contain octets 
     
    370370                    if protocol >= (1, 1): 
    371371                        # Encode RFC-2047 TEXT 
    372                         # (e.g. u"\u8200" -> "=?utf-8?b?6IiA?="). 
     372                        # (e.g. "\u8200" -> "=?utf-8?b?6IiA?="). 
    373373                        from email.Header import Header 
    374374                        v = Header(v, 'utf-8').encode() 
  • branches/py3k/cherrypy/lib/httpauth.py

    r1891 r2029  
    77 
    88    First use 'doAuth' to request the client authentication for a 
    9     certain resource. You should send an httplib.UNAUTHORIZED response to the 
    10     client so he knows he has to authenticate itself. 
     9    certain resource. You should send an http.client.UNAUTHORIZED 
     10    response to the client so he knows he has to authenticate itself. 
    1111     
    1212    Then use 'parseAuthorization' to retrieve the 'auth_map' used in 
     
    6060 
    6161################################################################################ 
    62 import md5 
     62from hashlib import md5 
    6363import time 
    6464import base64 
    65 import urllib2 
     65import urllib 
    6666 
    6767MD5 = "MD5" 
     
    7777# 
    7878DIGEST_AUTH_ENCODERS = { 
    79     MD5: lambda val: md5.new (val).hexdigest (), 
    80     MD5_SESS: lambda val: md5.new (val).hexdigest (), 
    81 #    SHA: lambda val: sha.new (val).hexdigest (), 
     79    MD5: lambda val: md5(val).hexdigest (), 
     80    MD5_SESS: lambda val: md5(val).hexdigest (), 
     81#    SHA: lambda val: sha1(val).hexdigest (), 
    8282} 
    8383 
     
    131131def _parseDigestAuthorization (auth_params): 
    132132    # Convert the auth params to a dict 
    133     items = urllib2.parse_http_list (auth_params) 
    134     params = urllib2.parse_keqv_list (items) 
     133    items = urllib.parse_http_list(auth_params) 
     134    params = urllib.parse_keqv_list(items) 
    135135 
    136136    # Now validate the params 
  • branches/py3k/cherrypy/lib/profiler.py

    r2012 r2029  
    6161import sys 
    6262 
    63 try: 
    64     import cStringIO as StringIO 
    65 except ImportError: 
    66     import StringIO 
     63import io 
    6764 
    6865 
     
    9592    def s