Skip to content

Commit b88c5f6

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 #979 which has been submitted upstream as benjaminp/six#176 but not yet merged.
1 parent 08c7749 commit b88c5f6

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

kafka/vendor/six.py

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pylint: skip-file
22
"""Utilities for writing code that runs on Python 2 and 3"""
33

4-
# Copyright (c) 2010-2015 Benjamin Peterson
4+
# Copyright (c) 2010-2017 Benjamin Peterson
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal
@@ -21,6 +21,8 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
# SOFTWARE.
2323

24+
"""Utilities for writing code that runs on Python 2 and 3"""
25+
2426
from __future__ import absolute_import
2527

2628
import functools
@@ -30,7 +32,7 @@
3032
import types
3133

3234
__author__ = "Benjamin Peterson <[email protected]>"
33-
__version__ = "1.10.0"
35+
__version__ = "1.11.0"
3436

3537

3638
# Useful for very coarse version differentiation.
@@ -71,7 +73,9 @@ def __len__(self):
7173
# 64-bit
7274
MAXSIZE = int((1 << 63) - 1)
7375

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

7781

@@ -244,6 +248,7 @@ class _MovedItems(_LazyModule):
244248
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
245249
MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
246250
MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
251+
MovedAttribute("getoutput", "commands", "subprocess"),
247252
MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
248253
MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"),
249254
MovedAttribute("reduce", "__builtin__", "functools"),
@@ -265,10 +270,11 @@ class _MovedItems(_LazyModule):
265270
MovedModule("html_entities", "htmlentitydefs", "html.entities"),
266271
MovedModule("html_parser", "HTMLParser", "html.parser"),
267272
MovedModule("http_client", "httplib", "http.client"),
273+
MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
274+
MovedModule("email_mime_image", "email.MIMEImage", "email.mime.image"),
268275
MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
269276
MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
270277
MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
271-
MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
272278
MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
273279
MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
274280
MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
@@ -340,10 +346,12 @@ class Module_six_moves_urllib_parse(_LazyModule):
340346
MovedAttribute("quote_plus", "urllib", "urllib.parse"),
341347
MovedAttribute("unquote", "urllib", "urllib.parse"),
342348
MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
349+
MovedAttribute("unquote_to_bytes", "urllib", "urllib.parse", "unquote", "unquote_to_bytes"),
343350
MovedAttribute("urlencode", "urllib", "urllib.parse"),
344351
MovedAttribute("splitquery", "urllib", "urllib.parse"),
345352
MovedAttribute("splittag", "urllib", "urllib.parse"),
346353
MovedAttribute("splituser", "urllib", "urllib.parse"),
354+
MovedAttribute("splitvalue", "urllib", "urllib.parse"),
347355
MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
348356
MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
349357
MovedAttribute("uses_params", "urlparse", "urllib.parse"),
@@ -419,6 +427,8 @@ class Module_six_moves_urllib_request(_LazyModule):
419427
MovedAttribute("URLopener", "urllib", "urllib.request"),
420428
MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
421429
MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
430+
MovedAttribute("parse_http_list", "urllib2", "urllib.request"),
431+
MovedAttribute("parse_keqv_list", "urllib2", "urllib.request"),
422432
]
423433
for attr in _urllib_request_moved_attributes:
424434
setattr(Module_six_moves_urllib_request, attr.name, attr)
@@ -682,11 +692,15 @@ def assertRegex(self, *args, **kwargs):
682692
exec_ = getattr(moves.builtins, "exec")
683693

684694
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
695+
try:
696+
if value is None:
697+
value = tp()
698+
if value.__traceback__ is not tb:
699+
raise value.with_traceback(tb)
700+
raise value
701+
finally:
702+
value = None
703+
tb = None
690704

691705
else:
692706
def exec_(_code_, _globs_=None, _locs_=None):
@@ -702,19 +716,28 @@ def exec_(_code_, _globs_=None, _locs_=None):
702716
exec("""exec _code_ in _globs_, _locs_""")
703717

704718
exec_("""def reraise(tp, value, tb=None):
705-
raise tp, value, tb
719+
try:
720+
raise tp, value, tb
721+
finally:
722+
tb = None
706723
""")
707724

708725

709726
if sys.version_info[:2] == (3, 2):
710727
exec_("""def raise_from(value, from_value):
711-
if from_value is None:
712-
raise value
713-
raise value from from_value
728+
try:
729+
if from_value is None:
730+
raise value
731+
raise value from from_value
732+
finally:
733+
value = None
714734
""")
715735
elif sys.version_info[:2] > (3, 2):
716736
exec_("""def raise_from(value, from_value):
717-
raise value from from_value
737+
try:
738+
raise value from from_value
739+
finally:
740+
value = None
718741
""")
719742
else:
720743
def raise_from(value, from_value):
@@ -805,10 +828,14 @@ def with_metaclass(meta, *bases):
805828
# This requires a bit of explanation: the basic idea is to make a dummy
806829
# metaclass for one level of class instantiation that replaces itself with
807830
# the actual metaclass.
808-
class metaclass(meta):
831+
class metaclass(type):
809832

810833
def __new__(cls, name, this_bases, d):
811834
return meta(name, bases, d)
835+
836+
@classmethod
837+
def __prepare__(cls, name, this_bases):
838+
return meta.__prepare__(name, bases)
812839
return type.__new__(metaclass, 'temporary_class', (), {})
813840

814841

0 commit comments

Comments
 (0)