~ubuntu-branches/ubuntu/trusty/python-urllib3/trusty-proposed

« back to all changes in this revision

Viewing changes to urllib3/packages/six.py

  • Committer: Package Import Robot
  • Author(s): Daniele Tricoli, Jakub Wilk, Daniele Tricoli
  • Date: 2013-05-11 15:15:38 UTC
  • mfrom: (1.2.1) (4.2.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: package-import@ubuntu.com-20130511151538-4dshl34jt0kkpt9i
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Daniele Tricoli ]
* New upstream release
* Upload to unstable (Closes: #707780)
* debian/control
  - Added python3-six to Build-Depends field
  - Bumped debhelper dependency to 8.1 for build-{arch,indep} support
  - Removed python-setuptools from Build-Depends field
* debian/copyright
  - Updated copyright years
  - Added stanza for urllib3/packages/ordered_dict.py
* debian/patches/01_do-not-use-embedded-python-six.patch
  - Refreshed
* debian/patches/02_require-cert-verification.patch
  - Refreshed
* debian/patches/03_no-setuptools.patch
  - Do not use setuptools
* debian/patches/04_relax_nosetests_options.patch
  - Do not use logging-clear-handlers to see all logging output and
    disabled cover-min-percentage since it require python-nose (>= 1.3):
    this way it will be easier to backport python-urllib3 to Wheezy.
* debian/patches/05_fix_python3_syntax_error_in_ntlmpool.patch
  - Fix syntax error 'unicodeescape' codec can't decode bytes in
    position 130-132 for Python3

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import types
25
25
 
26
26
__author__ = "Benjamin Peterson <benjamin@python.org>"
27
 
__version__ = "1.1.0"
 
27
__version__ = "1.2.0"  # Revision 41c74fef2ded
28
28
 
29
29
 
30
30
# True if we are running on Python 3.
45
45
    text_type = unicode
46
46
    binary_type = str
47
47
 
48
 
    # It's possible to have sizeof(long) != sizeof(Py_ssize_t).
49
 
    class X(object):
50
 
        def __len__(self):
51
 
            return 1 << 31
52
 
    try:
53
 
        len(X())
54
 
    except OverflowError:
55
 
        # 32-bit
 
48
    if sys.platform.startswith("java"):
 
49
        # Jython always uses 32 bits.
56
50
        MAXSIZE = int((1 << 31) - 1)
57
51
    else:
58
 
        # 64-bit
59
 
        MAXSIZE = int((1 << 63) - 1)
60
 
    del X
 
52
        # It's possible to have sizeof(long) != sizeof(Py_ssize_t).
 
53
        class X(object):
 
54
            def __len__(self):
 
55
                return 1 << 31
 
56
        try:
 
57
            len(X())
 
58
        except OverflowError:
 
59
            # 32-bit
 
60
            MAXSIZE = int((1 << 31) - 1)
 
61
        else:
 
62
            # 64-bit
 
63
            MAXSIZE = int((1 << 63) - 1)
 
64
            del X
61
65
 
62
66
 
63
67
def _add_doc(func, doc):
132
136
_moved_attributes = [
133
137
    MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
134
138
    MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
 
139
    MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
135
140
    MovedAttribute("map", "itertools", "builtins", "imap", "map"),
136
141
    MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
137
142
    MovedAttribute("reduce", "__builtin__", "functools"),
178
183
    setattr(_MovedItems, attr.name, attr)
179
184
del attr
180
185
 
181
 
moves = sys.modules["six.moves"] = _MovedItems("moves")
 
186
moves = sys.modules[__name__ + ".moves"] = _MovedItems("moves")
182
187
 
183
188
 
184
189
def add_move(move):
219
224
    _iteritems = "iteritems"
220
225
 
221
226
 
 
227
try:
 
228
    advance_iterator = next
 
229
except NameError:
 
230
    def advance_iterator(it):
 
231
        return it.next()
 
232
next = advance_iterator
 
233
 
 
234
 
222
235
if PY3:
223
236
    def get_unbound_function(unbound):
224
237
        return unbound
225
238
 
226
 
 
227
 
    advance_iterator = next
 
239
    Iterator = object
228
240
 
229
241
    def callable(obj):
230
242
        return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
232
244
    def get_unbound_function(unbound):
233
245
        return unbound.im_func
234
246
 
 
247
    class Iterator(object):
235
248
 
236
 
    def advance_iterator(it):
237
 
        return it.next()
 
249
        def next(self):
 
250
            return type(self).__next__(self)
238
251
 
239
252
    callable = callable
240
253
_add_doc(get_unbound_function,
249
262
 
250
263
def iterkeys(d):
251
264
    """Return an iterator over the keys of a dictionary."""
252
 
    return getattr(d, _iterkeys)()
 
265
    return iter(getattr(d, _iterkeys)())
253
266
 
254
267
def itervalues(d):
255
268
    """Return an iterator over the values of a dictionary."""
256
 
    return getattr(d, _itervalues)()
 
269
    return iter(getattr(d, _itervalues)())
257
270
 
258
271
def iteritems(d):
259
272
    """Return an iterator over the (key, value) pairs of a dictionary."""
260
 
    return getattr(d, _iteritems)()
 
273
    return iter(getattr(d, _iteritems)())
261
274
 
262
275
 
263
276
if PY3: