Skip to content

Commit 477ab74

Browse files
committed
Bump vendored six to 1.11.0
Bump `six` to `1.11.0`. Most changes do not affect us, but it's good to stay up to date. Also, we will likely start vendoring `enum34` in which case benjaminp/six#178 is needed. Note that this preserves the `kafka-python` customization from dpkp#979 which has been submitted upstream as benjaminp/six#176 but not yet merged.
1 parent 0c3f2c1 commit 477ab74

File tree

1 file changed

+42
-16
lines changed

1 file changed

+42
-16
lines changed

kafka/vendor/six.py

+42-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# pylint: skip-file
2-
"""Utilities for writing code that runs on Python 2 and 3"""
32

4-
# Copyright (c) 2010-2015 Benjamin Peterson
3+
# Copyright (c) 2010-2017 Benjamin Peterson
54
#
65
# Permission is hereby granted, free of charge, to any person obtaining a copy
76
# of this software and associated documentation files (the "Software"), to deal
@@ -21,6 +20,8 @@
2120
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2221
# SOFTWARE.
2322

23+
"""Utilities for writing code that runs on Python 2 and 3"""
24+
2425
from __future__ import absolute_import
2526

2627
import functools
@@ -30,7 +31,7 @@
3031
import types
3132

3233
__author__ = "Benjamin Peterson <[email protected]>"
33-
__version__ = "1.10.0"
34+
__version__ = "1.11.0"
3435

3536

3637
# Useful for very coarse version differentiation.
@@ -71,7 +72,9 @@ def __len__(self):
7172
# 64-bit
7273
MAXSIZE = int((1 << 63) - 1)
7374

74-
# Don't del it here, cause with gc disabled this "leaks" to garbage
75+
# Don't del it here, cause with gc disabled this "leaks" to garbage.
76+
# Note: This is a kafka-python customization, details at:
77+
# https://github.com/dpkp/kafka-python/pull/979#discussion_r100403389
7578
# del X
7679

7780

@@ -244,6 +247,7 @@ class _MovedItems(_LazyModule):
244247
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
245248
MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
246249
MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
250+
MovedAttribute("getoutput", "commands", "subprocess"),
247251
MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
248252
MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"),
249253
MovedAttribute("reduce", "__builtin__", "functools"),
@@ -265,10 +269,11 @@ class _MovedItems(_LazyModule):
265269
MovedModule("html_entities", "htmlentitydefs", "html.entities"),
266270
MovedModule("html_parser", "HTMLParser", "html.parser"),
267271
MovedModule("http_client", "httplib", "http.client"),
272+
MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
273+
MovedModule("email_mime_image", "email.MIMEImage", "email.mime.image"),
268274
MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
269275
MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
270276
MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
271-
MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
272277
MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
273278
MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
274279
MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
@@ -340,10 +345,12 @@ class Module_six_moves_urllib_parse(_LazyModule):
340345
MovedAttribute("quote_plus", "urllib", "urllib.parse"),
341346
MovedAttribute("unquote", "urllib", "urllib.parse"),
342347
MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
348+
MovedAttribute("unquote_to_bytes", "urllib", "urllib.parse", "unquote", "unquote_to_bytes"),
343349
MovedAttribute("urlencode", "urllib", "urllib.parse"),
344350
MovedAttribute("splitquery", "urllib", "urllib.parse"),
345351
MovedAttribute("splittag", "urllib", "urllib.parse"),
346352
MovedAttribute("splituser", "urllib", "urllib.parse"),
353+
MovedAttribute("splitvalue", "urllib", "urllib.parse"),
347354
MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
348355
MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
349356
MovedAttribute("uses_params", "urlparse", "urllib.parse"),
@@ -419,6 +426,8 @@ class Module_six_moves_urllib_request(_LazyModule):
419426
MovedAttribute("URLopener", "urllib", "urllib.request"),
420427
MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
421428
MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
429+
MovedAttribute("parse_http_list", "urllib2", "urllib.request"),
430+
MovedAttribute("parse_keqv_list", "urllib2", "urllib.request"),
422431
]
423432
for attr in _urllib_request_moved_attributes:
424433
setattr(Module_six_moves_urllib_request, attr.name, attr)
@@ -682,11 +691,15 @@ def assertRegex(self, *args, **kwargs):
682691
exec_ = getattr(moves.builtins, "exec")
683692

684693
def reraise(tp, value, tb=None):
685-
if value is None:
686-
value = tp()
687-
if value.__traceback__ is not tb:
688-
raise value.with_traceback(tb)
689-
raise value
694+
try:
695+
if value is None:
696+
value = tp()
697+
if value.__traceback__ is not tb:
698+
raise value.with_traceback(tb)
699+
raise value
700+
finally:
701+
value = None
702+
tb = None
690703

691704
else:
692705
def exec_(_code_, _globs_=None, _locs_=None):
@@ -702,19 +715,28 @@ def exec_(_code_, _globs_=None, _locs_=None):
702715
exec("""exec _code_ in _globs_, _locs_""")
703716

704717
exec_("""def reraise(tp, value, tb=None):
705-
raise tp, value, tb
718+
try:
719+
raise tp, value, tb
720+
finally:
721+
tb = None
706722
""")
707723

708724

709725
if sys.version_info[:2] == (3, 2):
710726
exec_("""def raise_from(value, from_value):
711-
if from_value is None:
712-
raise value
713-
raise value from from_value
727+
try:
728+
if from_value is None:
729+
raise value
730+
raise value from from_value
731+
finally:
732+
value = None
714733
""")
715734
elif sys.version_info[:2] > (3, 2):
716735
exec_("""def raise_from(value, from_value):
717-
raise value from from_value
736+
try:
737+
raise value from from_value
738+
finally:
739+
value = None
718740
""")
719741
else:
720742
def raise_from(value, from_value):
@@ -805,10 +827,14 @@ def with_metaclass(meta, *bases):
805827
# This requires a bit of explanation: the basic idea is to make a dummy
806828
# metaclass for one level of class instantiation that replaces itself with
807829
# the actual metaclass.
808-
class metaclass(meta):
830+
class metaclass(type):
809831

810832
def __new__(cls, name, this_bases, d):
811833
return meta(name, bases, d)
834+
835+
@classmethod
836+
def __prepare__(cls, name, this_bases):
837+
return meta.__prepare__(name, bases)
812838
return type.__new__(metaclass, 'temporary_class', (), {})
813839

814840

0 commit comments

Comments
 (0)