Wrapt

Latest version: v1.17.2

Safety actively analyzes 714815 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 7 of 8

1.4.0

-------------

**New Features**

* Enhanced wrapt.decorator and wrapt.function_wrapper so they can be
applied to instance methods and class methods with the self/cls argument
being supplied correctly. This allows instance and class methods to be
used as decorators, with the instance or class type being able to be used
to hold any state required for the decorator.

**Bugs Fixed**

* Fixed process crash in extension when the wrapped object passed as first
argument to FunctionWrapper did not have a tp_descr_get callback for the
type at C code level. Now raised an AttributeError exception in line with
what Python implementation does.

1.3.1

-------------

**Bugs Fixed**

* The discover_post_import_hooks() function had not been added to the
top level wrapt module.

1.3.0

-------------

**New Features**

* Added a transient_function_wrapper decorator for applying a wrapper
function around a target function only for the life of a single function
call. The decorator is useful for performing mocking or pass through
data validation/modification when doing unit testing of packages.

1.2.1

-------------

**Bugs Fixed**

* In C implementation, not dealing with unbound method type creation
properly which would cause later problems when calling instance method
via the class type in certain circumstances. Introduced problem in 1.2.0.

* Eliminated compiler warnings due to missing casts in C implementation.

1.2.0

-------------

**New Features**

* Added an 'enabled' option to decorator and FunctionWrapper which can
be provided a boolean, or a function returning a boolean to allow the
work of the decorator to be disabled dynamically. When a boolean, is
used for decorator, the wrapper will not even be applied if 'enabled'
is False. If a function, then will be called prior to wrapper being
called and if returns False, then original wrapped function called
directly rather than the wrapper being called.

* Added in an implementation of a post import hook mechanism in line with
that described in PEP 369.

* Added in helper functions specifically designed to assist in performing
monkey patching of existing code.

**Features Changed**

* Collapsed functionality of _BoundMethodWrapper into _BoundFunctionWrapper
and renamed the latter to BoundFunctionWrapper. If deriving from the
FunctionWrapper class and needing to override the type of the bound
wrapper, the class attribute ``__bound_function_wrapper__`` should be set
in the derived FunctionWrapper class to the replacement type.

**Bugs Fixed**

* When creating a custom proxy by deriving from ObjectProxy and the custom
proxy needed to override __getattr__(), it was not possible to called the
base class ObjectProxy.__getattr__() when the C implementation of
ObjectProxy was being used. The derived class __getattr__() could also
get ignored.

* Using inspect.getargspec() now works correctly on bound methods when an
adapter function can be provided to decorator.

1.1.3

-------------

**New Features**

* Added a _self_parent attribute to FunctionWrapper and bound variants.
For the FunctionWrapper the value will always be None. In the case of the
bound variants of the function wrapper, the attribute will refer back
to the unbound FunctionWrapper instance. This can be used to get a back
reference to the parent to access or cache data against the persistent
function wrapper, the bound wrappers often being transient and only
existing for the single call.

**Improvements**

* Use interned strings to optimise name comparisons in the setattro()
method of the C implementation of the object proxy.

**Bugs Fixed**

* The pypy interpreter is missing operator.__index__() so proxying of that
method in the object proxy would fail. This is a bug in pypy which is
being addressed. Use operator.index() instead which pypy does provide
and which also exists for CPython.

* The pure Python implementation allowed the __wrapped__ attribute to be
deleted which could cause problems. Now raise a TypeError exception.

* The C implementation of the object proxy would crash if an attempt was
made to delete the __wrapped__ attribute from the object proxy. Now raise a
TypeError exception.

Page 7 of 8

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.