Skip to content

Commit 535623f

Browse files
jdbrettlangdon
authored andcommitted
chore: update wrapt to 1.12.1 (#1283)
1 parent a698fc1 commit 535623f

File tree

7 files changed

+120
-94
lines changed

7 files changed

+120
-94
lines changed

ddtrace/vendor/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
2727
Website: https://wrapt.readthedocs.io/en/latest/
2828
Source: https://github.com/GrahamDumpleton/wrapt/
29-
Version: 1.11.1
29+
Version: 1.12.1
3030
License: BSD 2-Clause "Simplified" License
3131
3232
Notes:
33-
`wrapt/__init__.py` was updated to include a copy of `wrapt`'s license: https://github.com/GrahamDumpleton/wrapt/blob/1.11.1/LICENSE
34-
3533
`setup.py` will attempt to build the `wrapt/_wrappers.c` C module
3634
3735
dogstatsd

ddtrace/vendor/wrapt/LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2013-2019, Graham Dumpleton
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24+
POSSIBILITY OF SUCH DAMAGE.

ddtrace/vendor/wrapt/__init__.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,4 @@
1-
"""
2-
Copyright (c) 2013-2019, Graham Dumpleton
3-
All rights reserved.
4-
5-
Redistribution and use in source and binary forms, with or without
6-
modification, are permitted provided that the following conditions are met:
7-
8-
* Redistributions of source code must retain the above copyright notice, this
9-
list of conditions and the following disclaimer.
10-
11-
* Redistributions in binary form must reproduce the above copyright notice,
12-
this list of conditions and the following disclaimer in the documentation
13-
and/or other materials provided with the distribution.
14-
15-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21-
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23-
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25-
POSSIBILITY OF SUCH DAMAGE.
26-
"""
27-
__version_info__ = ('1', '11', '1')
1+
__version_info__ = ('1', '12', '1')
282
__version__ = '.'.join(__version_info__)
293

304
from .wrappers import (ObjectProxy, CallableObjectProxy, FunctionWrapper,

ddtrace/vendor/wrapt/_wrappers.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,19 @@ static PyObject *WraptObjectProxy_complex(
13281328

13291329
/* ------------------------------------------------------------------------- */
13301330

1331+
static PyObject *WraptObjectProxy_mro_entries(
1332+
WraptObjectProxyObject *self, PyObject *args, PyObject *kwds)
1333+
{
1334+
if (!self->wrapped) {
1335+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
1336+
return NULL;
1337+
}
1338+
1339+
return Py_BuildValue("(O)", self->wrapped);
1340+
}
1341+
1342+
/* ------------------------------------------------------------------------- */
1343+
13311344
static PyObject *WraptObjectProxy_get_name(
13321345
WraptObjectProxyObject *self)
13331346
{
@@ -1746,6 +1759,10 @@ static PyMethodDef WraptObjectProxy_methods[] = {
17461759
{ "__round__", (PyCFunction)WraptObjectProxy_round, METH_NOARGS, 0 },
17471760
#endif
17481761
{ "__complex__", (PyCFunction)WraptObjectProxy_complex, METH_NOARGS, 0 },
1762+
#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7)
1763+
{ "__mro_entries__", (PyCFunction)WraptObjectProxy_mro_entries,
1764+
METH_VARARGS | METH_KEYWORDS, 0 },
1765+
#endif
17491766
{ NULL, NULL },
17501767
};
17511768

@@ -2007,6 +2024,8 @@ static int WraptPartialCallableObjectProxy_clear(
20072024
static void WraptPartialCallableObjectProxy_dealloc(
20082025
WraptPartialCallableObjectProxyObject *self)
20092026
{
2027+
PyObject_GC_UnTrack(self);
2028+
20102029
WraptPartialCallableObjectProxy_clear(self);
20112030

20122031
WraptObjectProxy_dealloc((WraptObjectProxyObject *)self);
@@ -2263,6 +2282,8 @@ static int WraptFunctionWrapperBase_clear(WraptFunctionWrapperObject *self)
22632282

22642283
static void WraptFunctionWrapperBase_dealloc(WraptFunctionWrapperObject *self)
22652284
{
2285+
PyObject_GC_UnTrack(self);
2286+
22662287
WraptFunctionWrapperBase_clear(self);
22672288

22682289
WraptObjectProxy_dealloc((WraptObjectProxyObject *)self);

ddtrace/vendor/wrapt/decorators.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,8 @@
66
import sys
77

88
PY2 = sys.version_info[0] == 2
9-
PY3 = sys.version_info[0] == 3
109

11-
if PY3:
12-
string_types = str,
13-
14-
import builtins
15-
exec_ = getattr(builtins, "exec")
16-
del builtins
17-
18-
else:
10+
if PY2:
1911
string_types = basestring,
2012

2113
def exec_(_code_, _globs_=None, _locs_=None):
@@ -30,6 +22,14 @@ def exec_(_code_, _globs_=None, _locs_=None):
3022
_locs_ = _globs_
3123
exec("""exec _code_ in _globs_, _locs_""")
3224

25+
else:
26+
string_types = str,
27+
28+
import builtins
29+
30+
exec_ = getattr(builtins, "exec")
31+
del builtins
32+
3333
from functools import partial
3434
from inspect import ismethod, isclass, formatargspec
3535
from collections import namedtuple
@@ -99,11 +99,6 @@ def __signature__(self):
9999
if 'signature' not in globals():
100100
return self._self_adapter.__signature__
101101
else:
102-
# Can't allow this to fail on Python 3 else it falls
103-
# through to using __wrapped__, but that will be the
104-
# wrong function we want to derive the signature
105-
# from. Thus generate the signature ourselves.
106-
107102
return signature(self._self_adapter)
108103

109104
if PY2:
@@ -117,6 +112,13 @@ def __func__(self):
117112
return _AdapterFunctionSurrogate(self.__wrapped__.__func__,
118113
self._self_parent._self_adapter)
119114

115+
@property
116+
def __signature__(self):
117+
if 'signature' not in globals():
118+
return self.__wrapped__.__signature__
119+
else:
120+
return signature(self._self_parent._self_adapter)
121+
120122
if PY2:
121123
im_func = __func__
122124

@@ -393,9 +395,12 @@ def _capture(target_wrapped):
393395

394396
# We first return our magic function wrapper here so we can
395397
# determine in what context the decorator factory was used. In
396-
# other words, it is itself a universal decorator.
398+
# other words, it is itself a universal decorator. The decorator
399+
# function is used as the adapter so that linters see a signature
400+
# corresponding to the decorator and not the wrapper it is being
401+
# applied to.
397402

398-
return _build(wrapper, _wrapper)
403+
return _build(wrapper, _wrapper, adapter=decorator)
399404

400405
else:
401406
# The wrapper still has not been provided, so we are just
@@ -493,7 +498,7 @@ def _synchronized_wrapper(wrapped, instance, args, kwargs):
493498
# desired context is held. If instance is None then the
494499
# wrapped function is used as the context.
495500

496-
with _synchronized_lock(instance or wrapped):
501+
with _synchronized_lock(instance if instance is not None else wrapped):
497502
return wrapped(*args, **kwargs)
498503

499504
class _FinalDecorator(FunctionWrapper):

ddtrace/vendor/wrapt/importer.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
import threading
88

99
PY2 = sys.version_info[0] == 2
10-
PY3 = sys.version_info[0] == 3
1110

12-
if PY3:
11+
if PY2:
12+
string_types = basestring,
13+
else:
1314
import importlib
1415
string_types = str,
15-
else:
16-
string_types = basestring,
1716

1817
from .decorators import synchronized
1918

@@ -188,7 +187,20 @@ def find_module(self, fullname, path=None):
188187
# Now call back into the import system again.
189188

190189
try:
191-
if PY3:
190+
if PY2:
191+
# For Python 2 we don't have much choice but to
192+
# call back in to __import__(). This will
193+
# actually cause the module to be imported. If no
194+
# module could be found then ImportError will be
195+
# raised. Otherwise we return a loader which
196+
# returns the already loaded module and invokes
197+
# the post import hooks.
198+
199+
__import__(fullname)
200+
201+
return _ImportHookLoader()
202+
203+
else:
192204
# For Python 3 we need to use find_spec().loader
193205
# from the importlib.util module. It doesn't actually
194206
# import the target module and only finds the
@@ -204,18 +216,6 @@ def find_module(self, fullname, path=None):
204216
if loader:
205217
return _ImportHookChainedLoader(loader)
206218

207-
else:
208-
# For Python 2 we don't have much choice but to
209-
# call back in to __import__(). This will
210-
# actually cause the module to be imported. If no
211-
# module could be found then ImportError will be
212-
# raised. Otherwise we return a loader which
213-
# returns the already loaded module and invokes
214-
# the post import hooks.
215-
216-
__import__(fullname)
217-
218-
return _ImportHookLoader()
219219

220220
finally:
221221
del self.in_progress[fullname]

ddtrace/vendor/wrapt/wrappers.py

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
import inspect
77

88
PY2 = sys.version_info[0] == 2
9-
PY3 = sys.version_info[0] == 3
109

11-
if PY3:
12-
string_types = str,
13-
else:
10+
if PY2:
1411
string_types = basestring,
12+
else:
13+
string_types = str,
1514

1615
def with_metaclass(meta, *bases):
1716
"""Create a base class with a metaclass."""
@@ -117,7 +116,7 @@ def __dir__(self):
117116
def __str__(self):
118117
return str(self.__wrapped__)
119118

120-
if PY3:
119+
if not PY2:
121120
def __bytes__(self):
122121
return bytes(self.__wrapped__)
123122

@@ -130,10 +129,14 @@ def __repr__(self):
130129
def __reversed__(self):
131130
return reversed(self.__wrapped__)
132131

133-
if PY3:
132+
if not PY2:
134133
def __round__(self):
135134
return round(self.__wrapped__)
136135

136+
if sys.hexversion >= 0x03070000:
137+
def __mro_entries__(self, bases):
138+
return (self.__wrapped__,)
139+
137140
def __lt__(self, other):
138141
return self.__wrapped__ < other
139142

@@ -736,33 +739,34 @@ def resolve_path(module, name):
736739
path = name.split('.')
737740
attribute = path[0]
738741

739-
original = getattr(parent, attribute)
740-
for attribute in path[1:]:
741-
parent = original
742-
743-
# We can't just always use getattr() because in doing
744-
# that on a class it will cause binding to occur which
745-
# will complicate things later and cause some things not
746-
# to work. For the case of a class we therefore access
747-
# the __dict__ directly. To cope though with the wrong
748-
# class being given to us, or a method being moved into
749-
# a base class, we need to walk the class hierarchy to
750-
# work out exactly which __dict__ the method was defined
751-
# in, as accessing it from __dict__ will fail if it was
752-
# not actually on the class given. Fallback to using
753-
# getattr() if we can't find it. If it truly doesn't
754-
# exist, then that will fail.
755-
756-
if inspect.isclass(original):
757-
for cls in inspect.getmro(original):
742+
# We can't just always use getattr() because in doing
743+
# that on a class it will cause binding to occur which
744+
# will complicate things later and cause some things not
745+
# to work. For the case of a class we therefore access
746+
# the __dict__ directly. To cope though with the wrong
747+
# class being given to us, or a method being moved into
748+
# a base class, we need to walk the class hierarchy to
749+
# work out exactly which __dict__ the method was defined
750+
# in, as accessing it from __dict__ will fail if it was
751+
# not actually on the class given. Fallback to using
752+
# getattr() if we can't find it. If it truly doesn't
753+
# exist, then that will fail.
754+
755+
def lookup_attribute(parent, attribute):
756+
if inspect.isclass(parent):
757+
for cls in inspect.getmro(parent):
758758
if attribute in vars(cls):
759-
original = vars(cls)[attribute]
760-
break
759+
return vars(cls)[attribute]
761760
else:
762-
original = getattr(original, attribute)
763-
761+
return getattr(parent, attribute)
764762
else:
765-
original = getattr(original, attribute)
763+
return getattr(parent, attribute)
764+
765+
original = lookup_attribute(parent, attribute)
766+
767+
for attribute in path[1:]:
768+
parent = original
769+
original = lookup_attribute(parent, attribute)
766770

767771
return (parent, attribute, original)
768772

0 commit comments

Comments
 (0)