Commits

Lynn Rees committed 3c92393

- beginning 3.x compatibility

  • Participants
  • Parent commits 792896a
  • Branches pu

Comments (0)

Files changed (28)

File wire/http/request/client.py

 # -*- coding: utf-8 -*-
 '''wire HTTP request core'''
 
-from stuf.utils import exhaust
 from appspace.keys import appifies
 from callchain.internal import inside
+from stuf.utils import OrderedDict, exhaust
 from twoq.lazy.mixins import AutoResultMixin
+from callchain.assembly.chain import CallChainQ
 from callchain.mixin.reset import ResetTypeMixin
 
-from callchain.assembly.chain import CallChainQ
-
 from wire.http.request.apps import apps
 from wire.http.request.keys.client import KRequestClient
-from collections import OrderedDict
 
 
 class Request(ResetTypeMixin):
 
+    '''request wrapper'''
+
     def __init__(self, url, verify, allow_redirects, timeout, auth, proxy):
         super(Request, self).__init__()
         self.url = url
         super(http, self).__init__(pattern, required, defaults, **kw)
         # files demand multipart as default otherwise go with urlencode
         _setdefault = self._setdefault
-        _defaults = self.defaultss
-        _setdefault('_format', kw.get('format'), _defaults.format)
+        _defaults = self.defaults
         # allow redirects
         _setdefault('_redirects', kw.get('redirects'), _defaults.redirects)
         # cert verification
         # authentication
         auth = config.pop('auth', self._auth)
         if auth:
-            self.authentication(*auth)
+            self.auth(*auth)
         randomua = config.get('randomua', self._randomua)
         # proxy
         proxy = config.pop('proxy', self._proxy)
             u, verify, allow_redirects, timeout, auth, proxy, randomua
         ) for u in urls))
 
+    ###########################################################################
+    ## usage management #######################################################
+    ###########################################################################
+
+    def clear(self):
+        '''clear all queues'''
+        self._resetdefaults()
+        self._qclear()
+        return self
+
+    def auth(self, username, password):
+        '''
+        set authentication settings
+
+        @param username: usernameish credential
+        @param password: passwordish credential
+        '''
+        self._auth = (username, password)
+        return self
+
+    def proxy(self, server, host):
+        '''
+        set proxy settings
+
+        @param server: proxy server
+        @param host: proxy host
+        '''
+        self._proxy = (server, host)
+        return self
+
+    ###########################################################################
+    ## http methods ###########################################################
+    ###########################################################################
+
     @property
     def _requester(self):
+        '''fetch http requester'''
         return self.M.get(self.G.request, self.G.userspace)
 
     def _pack(self, method):
             exhaust(pack(i) for i in sync.interable)
         self.commit()
         return self
-    
-    def clear(self):
-        '''clear all queues'''
-        self._resetdefaults()
-        self._qclear()
-        return self
 
     def get(self):
         '''
         http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.8
         '''
         return self._pack('TRACE')
-
-    def auth(self, username, password):
-        '''
-        set authentication settings
-        
-        @param username: username credential
-        @param password: password credential
-        '''
-        self._auth = (username, password)
-        return self
-
-    def proxy(self, server, host):
-        '''
-        proxy settings
-        
-        @param server: proxy server
-        @param host: proxy host
-        '''
-        self._proxy = (server, host)
-        return self

File wire/http/request/cookie.py

 # -*- coding: utf-8 -*-
 '''wire HTTP cookie management'''
 
-import Cookie as _cook
 from functools import partial
-from Cookie import SimpleCookie, Morsel
 
 from stuf.utils import exhaustmap
 from twoq.support import isstring
 from appspace.keys import appifies
+from stuf.six.moves import http_cookies  # @UnresolvedImport
 
 from wire.http.httplet import httplet
 from wire.http.request.keys.header import KRequestCookie
 
 
-class Cookie(SimpleCookie):
+class Cookie(http_cookies.SimpleCookie):
 
     '''HTTP request specific cookie'''
 
         self._set(key, rval, cval)
 
     def _set(self, k, real_value, coded_value):
-        m = self.get(k, Morsel())
+        m = self.get(k, http_cookies.Morsel())
         m.set(k, real_value, coded_value)
         dict.__setitem__(self, k, m)
 
-    def set(self, key, field, value):
-        m = self.get(key, Morsel())
-        if key.lower() in m._reserved:
-            m[field] = _cook._unquote(value)
-        else:
-            real_value, coded_value = self.value_decode(value)
-            m.set(field, real_value, coded_value)
-        dict.__setitem__(self, key, m)
-
-    def _parse(self, cookie, patt=_cook._CookiePattern):
+    def _parse(self, cookie, patt=http_cookies._CookiePattern):
         i = 0  # Our starting point
         n = len(cookie)  # Length of string
         m = None  # current morsel
-        unquote = _cook._unquote
-        reserved = Morsel._reserved
+        unquote = http_cookies._unquote
+        reserved = http_cookies.Morsel._reserved
         value_decode = self.value_decode
         setter = self._set
         this = self
     def dumps(self):
         return partial(self.output, header='cookie:')
 
+    def set(self, key, field, value):
+        m = self.get(key, http_cookies.Morsel())
+        if key.lower() in m._reserved:
+            m[field] = http_cookies._unquote(value)
+        else:
+            real_value, coded_value = self.value_decode(value)
+            m.set(field, real_value, coded_value)
+        dict.__setitem__(self, key, m)
+
 
 @appifies(KRequestCookie)
 class RequestCookie(httplet):

File wire/http/request/header.py

 
 import re
 from random import choice
-from itertools import chain
 from datetime import datetime
 from email.header import Header
+from itertools import chain, starmap
 
-from appspace.keys import appifies, imap
-from stuf.utils import OrderedDict, lazy_class, exhaust, iterexcept
+from appspace.keys import appifies
+from twoq.support import isstring, isunicode
+from stuf.utils import OrderedDict, lazy_class, exhaust
 
 from wire.http.util import httpdate
 from wire.http.header import CoreHeaders
             ),
         }
 
+    def _headers(self, headers):
+        '''
+        HTTP request headers setter
+
+        @param headers: HTTP headers
+        '''
+        header = self.header
+        exhaust(starmap(header, (i for i in headers)))
+        return self
+
     @classmethod
     def _validate(self, key, value):
         '''
         @param value Putative header value
         '''
         err_msg = None
-        if not isinstance(value, basestring):
+        if not isstring(value):
             return True
         # Don't allow request headers
         if key in self._RESPONSE:
         if not isinstance(key, str):
             err_msg = 'HTTP header name must be non-Unicode string'
         # Don't allow unicode header values outside RFC2822
-        elif isinstance(value, unicode):
+        elif isunicode(value):
             err_msg = 'use "set_rfc2822" to set Unicode HTTP header values'
         # Don't allow "status" to be set in headers
         elif key == 'status':
         elif key.endswith('-') or key.endswith('_'):
             err_msg = 'HTTP header name may not end in "-" or "_"'
         # No control characters in header name
-        elif isinstance(value, basestring) and self._badheaders.search(value):
+        elif isstring(value) and self._badheaders.search(value):
             err_msg = 'Bad character %r in HTTP header value %r' % (
                 self._badheaders.search(value).group(0), value
             )
         else:
             headers[key] = value
         return self
-
-    def headers(self, headers):
-        '''
-        HTTP request headers setter
-
-        @param headers: HTTP headers
-        '''
-        header = self.header
-        exhaust(imap(header, iterexcept(headers, IndexError)))
-        return self

File wire/http/response/data.py

 '''wire core HTTP response'''
 
-from StringIO import StringIO
+from hashlib import md5
+
+from six.moves import StringIO  # @UnresolvedImport
 
 from callchain.root.linked import chainlink
 
         '''Verify MD5 digest of response data against "Content-MD5" digest'''
         digest = self.headers.content_md5
         if digest is not None and digest:
-            import md5
             from base64 import b64decode
             digest = b64decode(digest)
             body_digest = md5.new(self._original).digest()

File wire/http/response/header.py

 '''wire core HTTP response'''
+
 from stuf.utils import lazy_class
+from twoq.support import isstring
+
 from wire.http.util import datehttp
 from wire.http.header import CoreHeaders
 
         @param value: Value to format if required
         '''
         # Keep nulls out of the pipeline
-        if isinstance(value, basestring):
+        if isstring(value):
         # Request HTTP variables to cast to integers
             if key in set(['accept-ranges', 'age', 'content-length']):
                 value = cls._parseint(value)

File wire/http/util.py

 
 import time
 from datetime import datetime
-from rfc822 import formatdate, parsedate_tz
-from BaseHTTPServer import BaseHTTPRequestHandler as _bhrh
+
+from six.moves import formatdate, parsedate_tz  # @UnresolvedImport
+from six.moves.BaseHTTPServer import BaseHTTPRequestHandler  # @UnresolvedImport @IgnorePep8
 
 
 def datehttp(value):
 
     @param code: HTTP response (integer)
     '''
-    return _bhrh.responses[code][1]
+    return BaseHTTPRequestHandler.responses[code][1]
 
 
 def statuscode(code):
 
     @param code: HTTP response code (integer)
     '''
-    return '{0} {1}'.format(code, _bhrh.responses[code][0])
+    return '{0} {1}'.format(code, BaseHTTPRequestHandler.responses[code][0])

File wire/talk/csvw.py

 '''comma-separated values <-> Python talk'''
 
 import csv
-from cStringIO import StringIO
 
+from six.moves import StringIO  # @UnresolvedImport
 from appspace.keys import appifies
 from callchain.mixin.reset import ResetLocalMixin
 

File wire/talk/excelw.py

 # -*- coding: utf-8 -*-
 '''M$ Excel <-> Python talk'''
 
-from cStringIO import StringIO
-
 import xlrd
 import xlwt
+from six.moves import StringIO  # @UnresolvedImport
 from appspace.keys import appifies
 from callchain.mixin.reset import ResetLocalMixin
 

File wire/talk/msgpackw.py

 '''Message Pack <-> Python talk'''
 
 import msgpack
-
 from appspace.keys import appifies
 from callchain.mixin.reset import ResetLocalMixin
 

File wire/talk/multipartw.py

 '''multipart <-> Python talk'''
 
 from operator import setitem
-from StringIO import StringIO
 from cgi import parse_multipart
 
+from six.moves import StringIO  # @UnresolvedImport
 from stuf.utils import exhaustmap
 from appspace.keys import appifies
 from callchain.mixin.reset import ResetLocalMixin

File wire/talk/plistw.py

 # -*- coding: utf-8 -*-
 '''plist <-> Python talk'''
 
-from plistlib import readPlistFromString, writePlistToString
-
 from appspace.keys import appifies
+from six.moves import read_plist, write_plist  # @UnresolvedImport
 from callchain.mixin.reset import ResetLocalMixin
 
 from wire.talk.keys import KPlistDumps, KPlistLoads
 
     def plist(self):
         '''plist serialization'''
-        dump = readPlistFromString
+        dump = read_plist
         with self._sync as sync:
             sync(dump(d) for d in sync.iterable)
         return self
 
     def plist(self):
         '''plist serialization'''
-        load = writePlistToString
+        load = write_plist
         with self._sync as sync:
             sync(load(d) for d in sync.iterable)
         return self

File wire/talk/urlw.py

 # -*- coding: utf-8 -*-
 '''urlencode <-> Python talk'''
 
-import urllib
 from operator import setitem
-try:
-    from urlparse import parse_qs
-except ImportError:
-    from cgi import parse_qs
 
 from stuf.utils import exhaustmap
 from appspace.keys import appifies
+from stuf.six.moves import parse_qs, urlencode  # @UnresolvedImport
 from callchain.mixin.reset import ResetLocalMixin
 
 from wire.talk.keys import KUrlEncodeDumps, KUrlEncodeLoads
 
     def urlencode(self, **kw):
         '''urlencode serialization'''
-        dump = urllib.urlencode
+        dump = urlencode
         with self._sync as sync:
             sync(dump(d, **kw) for d in sync.iterable)
         return self

File wire/talk/xmlrpcw.py

 # -*- coding: utf-8 -*-
 '''XML-RPC <-> Python talk'''
 
-import xmlrpclib
-
 from appspace.keys import appifies
+from six.moves.xmlrpc import dumps, loads  # @UnresolvedImport
 from callchain.mixin.reset import ResetLocalMixin
 
 from wire.talk.keys import KXmlRpcDumps, KXmlRpcLoads
 
     def xmlrpc(self, **kw):
         '''xmlrpc serialization'''
-        dumps = xmlrpclib.dumps
+        dumps = dumps
         with self._sync as sync:
             sync(dumps(d, **kw) for d in sync.iterable)
         return self
 
     def xmlrpc(self, **kw):
         '''xmlrpc serialization'''
-        loads = xmlrpclib.loads
+        loads = loads
         with self._sync as sync:
             sync(loads(d, **kw)[0] for d in sync.iterable)
         return self

File wire/test/test/test_bson.py

 
 import unittest
 
+from stuf.six import strings, u
+
 
 class TestBson(unittest.TestCase):
 
 
     def setUp(self):
         self.talker = self._makeone
-        self.obj = {u'name': 'obj', u'types': [1, u'string', 3.5]}
+        self.obj = {u('name'): 'obj', u('types'): [1, u('string'), 3.5]}
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj, newobj)
 
 
     def setUp(self):
         self.talker = self._makeone()
-        self.obj = {u'name': 'obj', u'types': [1, u'string', 3.5]}
+        self.obj = {u('name'): 'obj', u('types'): [1, u('string'), 3.5]}
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj, newobj)
 

File wire/test/test/test_csv.py

 '''CSV tests'''
 
 import unittest
+from stuf.six import strings
 
 
 class TestCSV(unittest.TestCase):
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.should, newobj)
 
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.should, newobj)
 

File wire/test/test/test_excel.py

 '''Excel tests'''
 
 import unittest
+from stuf.six import strings, u
 
 
 class TestExcel(unittest.TestCase):
     def setUp(self):
         self.talker = self._makeone
         self.obj = [
-            [u'name', u'obj', u'types', 1, u'string', 3.5, 3],
-            [u'name2', u'obj2', u'types2', 2, u'string2', 4.5, 3],
+            [u('name'), u('obj'), u('types'), 1, u('string'), 3.5, 3],
+            [u('name2'), u('obj2'), u('types2'), 2, u('string2'), 4.5, 3],
         ]
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual([self.obj], newobj, newobj)
 
     def setUp(self):
         self.talker = self._makeone()
         self.obj = [
-            [u'name', u'obj', u'types', 1, u'string', 3.5, 3],
-            [u'name2', u'obj2', u'types2', 2, u'string2', 4.5, 3],
+            [u('name'), u('obj'), u('types'), 1, u('string'), 3.5, 3],
+            [u('name2'), u('obj2'), u('types2'), 2, u('string2'), 4.5, 3],
         ]
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual([self.obj], newobj, newobj)
 

File wire/test/test/test_html.py

 '''HTML tests'''
 
 import unittest
+from stuf.six import strings, u
 
 
 class TestHTML(unittest.TestCase):
         except ImportError:
             raise ImportWarning('HTML talker needs "lxml" library')
         self.talker = self._makeone
-        self.obj = fromstring(
-            u'<html>'
-            u'<head>'
-            u'<title>test</title>'
-            u'</head>'
-            u'<body>'
-            u'<p class=6>obj'
-            u'<div type="list">'
-            u'<span>1</span>'
-            u'<SPAN>string'
-            u'<span>3.5</float>'
-            u'</div>'
-            u'</body>'
-            u'</html>',
-        )
+        self.obj = fromstring(u(
+            '<html>'
+            '<head>'
+            '<title>test</title>'
+            '</head>'
+            '<body>'
+            '<p class=6>obj'
+            '<div type="list">'
+            '<span>1</span>'
+            '<SPAN>string'
+            '<span>3.5</float>'
+            '</div>'
+            '</body>'
+            '</html>',
+        ))
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         from lxml.html import tostring
         self.assertEqual(tostring(self.obj), tostring(newobj))
         except ImportError:
             raise ImportWarning('HTML talker needs "lxml" library')
         self.talker = self._makeone()
-        self.obj = fromstring(
-            u'<html>'
-            u'<head>'
-            u'<title>test</title>'
-            u'</head>'
-            u'<body>'
-            u'<p class=6>obj'
-            u'<div type="list">'
-            u'<span>1</span>'
-            u'<SPAN>string'
-            u'<span>3.5</float>'
-            u'</div>'
-            u'</body>'
-            u'</html>',
-        )
+        self.obj = fromstring(u(
+            '<html>'
+            '<head>'
+            '<title>test</title>'
+            '</head>'
+            '<body>'
+            '<p class=6>obj'
+            '<div type="list">'
+            '<span>1</span>'
+            '<SPAN>string'
+            '<span>3.5</float>'
+            '</div>'
+            '</body>'
+            '</html>',
+        ))
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         from lxml.html import tostring
         self.assertEqual(tostring(self.obj), tostring(newobj))

File wire/test/test/test_json.py

 '''json tests'''
 
 import unittest
+from stuf.six import strings
 
 
 class TestJson(unittest.TestCase):
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj)
 
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj)
 

File wire/test/test/test_marshal.py

 '''marshal tests'''
 
 import unittest
+from stuf.six import strings
 
 
 class TestMarshal(unittest.TestCase):
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj)
 
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj)
 

File wire/test/test/test_multipart.py

 
 import unittest
 
+from stuf.six import u, strings
+
 
 class TestMultiPart(unittest.TestCase):
 
     def setUp(self):
         self.talker = self._makeone
         self.should = {
-            u'name': u'obj',
-            u'types': u'1',
-            u'string': u'3.5',
+            u('name'): u('obj'),
+            u('types'): u('1'),
+            u('string'): u('3.5'),
         }
         self.obj = {
             'form': {
     def test_talk(self):
         self.maxDiff = None
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertDictContainsSubset(self.should, newobj)
 
     def setUp(self):
         self.talker = self._makeone()
         self.should = {
-            u'name': u'obj',
-            u'types': u'1',
-            u'string': u'3.5',
+            u('name'): u('obj'),
+            u('types'): u('1'),
+            u('string'): u('3.5'),
         }
         self.obj = {
             'form': {
                 'name': 'obj',
                 'types': '1',
-                u'string': '3.5',
+                u('string'): '3.5',
             },
             'files': {
                 'multjpg': open('fixture/multipart.jpg', 'rb'),
     def test_talk(self):
         self.maxDiff = None
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertDictContainsSubset(self.should, newobj)
 

File wire/test/test/test_pickle.py

 '''Pickle tests'''
 
 import unittest
+from stuf.six import strings
 
 
 class TestPickle(unittest.TestCase):
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj)
 
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj)
 

File wire/test/test/test_protobuf.py

 '''protobuf tests'''
 
 import unittest
+from stuf.six import strings
 
 
 class TestProtobuf(unittest.TestCase):
     def test_talk(self):
         from wire.talk.test.fixture.test_pb2 import Test
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped, proto=Test)
         self.assertEqual(self.obj, newobj)
 
     def test_talk(self):
         from wire.talk.test.fixture.test_pb2 import Test
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped, proto=Test)
         self.assertEqual(self.obj, newobj)
 

File wire/test/test/test_thrift.py

 '''thrift tests'''
 
 import unittest
+from stuf.six import strings
 
 
 class TestThrift(unittest.TestCase):
     def test_talk(self):
         from wire.talk.test.fixture.WireTest.constants import Test
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped, thrift_base_type=Test())
         self.assertEqual(self.obj, newobj)
 
     def test_talk(self):
         from wire.talk.test.fixture.WireTest.constants import Test
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped, thrift_base_type=Test())
         self.assertEqual(self.obj, newobj)
 

File wire/test/test/test_url.py

 '''urlencode tests'''
 
 import unittest
+from stuf.six import strings, u
 
 
 class TestURL(unittest.TestCase):
     def setUp(self):
         self.should = {'name': 'obj', 'types': '1', 'string': '3.5'}
         self.talker = self._makeone
-        self.obj = {'name': 'obj', 'types': 1, u'string': 3.5}
+        self.obj = {'name': 'obj', 'types': 1, u('string'): 3.5}
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.should, newobj)
 
     def setUp(self):
         self.should = {'name': 'obj', 'types': '1', 'string': '3.5'}
         self.talker = self._makeone()
-        self.obj = {'name': 'obj', 'types': 1, u'string': 3.5}
+        self.obj = {'name': 'obj', 'types': 1, u('string'): 3.5}
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.should, newobj)
 

File wire/test/test/test_xml.py

 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         try:
             from lxml.etree import tostring
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         try:
             from lxml.etree import tostring

File wire/test/test/test_xmlrpc.py

 '''XML-RPC tests'''
 
 import unittest
+from stuf.six import strings
 
 
 class TestXMLRPC(unittest.TestCase):
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj)
 
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertEqual(self.obj, newobj)
 

File wire/test/test/test_yaml.py

 '''YaML tests'''
 
 import unittest
+from stuf.six import strings
 
 
 class TestYaml(unittest.TestCase):
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertDictEqual(self.obj, newobj)
 
 
     def test_talk(self):
         dumped = self.talker.dumps(self.obj)
-        self.assertIsInstance(dumped, basestring)
+        self.assertIsInstance(dumped, strings)
         newobj = self.talker._loads(dumped)
         self.assertDictEqual(self.obj, newobj)
 

File wire/util.py

 
 import mimetypes
 
+from six.moves import range  # @UnresolvedImport
+
 
 def content_type(filename):
     '''content type of file'''
         return os.urandom(16)
     except:
         import random
-        return ''.join(list(chr(random.randrange(256)) for i in xrange(16)))
+        return ''.join(list(chr(random.randrange(256)) for i in range(16)))
 
 
 def subdict(somedict, somekeys, default=None):