Ticket #7831: urlpath-python3-2.patch

File urlpath-python3-2.patch, 2.4 KB (added by _sunu_, 6 years ago)
  • twisted/python/dist3.py

    diff --git twisted/python/dist3.py twisted/python/dist3.py
    index 3092ccd..4b31291 100644
    modules = [ 
    122122    "twisted.python.test.modules_helpers",
    123123    "twisted.python.threadable",
    124124    "twisted.python.threadpool",
     125    "twisted.python.urlpath",
    125126    "twisted.python.usage",
    126127    "twisted.python.util",
    127128    "twisted.python.versions",
    testModules = [ 
    211212    "twisted.python.test.test_runtime",
    212213    "twisted.python.test.test_systemd",
    213214    "twisted.python.test.test_tzhelper",
     215    "twisted.python.test.test_urlpath",
    214216    "twisted.python.test.test_util",
    215217    "twisted.python.test.test_versions",
    216218    "twisted.test.testutils",
  • twisted/python/urlpath.py

    diff --git twisted/python/urlpath.py twisted/python/urlpath.py
    index 1c15f09..11cc767 100644
     
    1 # -*- test-case-name: twisted.test.test_paths -*-
     1# -*- test-case-name: twisted.test.test_urlpath -*-
    22# Copyright (c) Twisted Matrix Laboratories.
    33# See LICENSE for details.
    44
    55#
    66
    7 import urlparse
    8 import urllib
     7from __future__ import division, absolute_import
    98
    10 class URLPath:
     9from twisted.python.compat import _PY3
     10if not _PY3:
     11    import urlparse
     12    from urllib import unquote as unquoteFunc
     13else:
     14    import urllib.parse as urlparse
     15    from urllib.parse import unquote as unquoteFunc
     16
     17
     18
     19class URLPath(object):
    1120    def __init__(self, scheme='', netloc='localhost', path='',
    1221                 query='', fragment=''):
    1322        self.scheme = scheme or 'http'
    class URLPath: 
    1827
    1928    _qpathlist = None
    2029    _uqpathlist = None
    21    
     30
    2231    def pathList(self, unquote=0, copy=1):
    2332        if self._qpathlist is None:
    2433            self._qpathlist = self.path.split('/')
    25             self._uqpathlist = map(urllib.unquote, self._qpathlist)
     34            self._uqpathlist = map(unquoteFunc, self._qpathlist)
    2635        if unquote:
    2736            result = self._uqpathlist
    2837        else:
    class URLPath: 
    101110                l = self.pathList()
    102111                l[-1] = path
    103112                path = '/'.join(l)
    104        
     113
    105114        return URLPath(scheme,
    106115                        netloc,
    107116                        path,
    class URLPath: 
    109118                        fragment)
    110119
    111120
    112    
     121
    113122    def __str__(self):
    114123        x = urlparse.urlunsplit((
    115124            self.scheme, self.netloc, self.path,