wrapt 2.5.1.dev1__tar.gz → 2.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {wrapt-2.5.1.dev1/src/wrapt.egg-info → wrapt-2.5.2}/PKG-INFO +1 -1
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/__init__.py +1 -1
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/proxies.py +25 -12
- {wrapt-2.5.1.dev1 → wrapt-2.5.2/src/wrapt.egg-info}/PKG-INFO +1 -1
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_auto_object_proxy.py +224 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_lazy_object_proxy.py +43 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tox.ini +0 -1
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/LICENSE +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/MANIFEST.in +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/README.md +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/RELEASE.rst +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/pyproject.toml +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/setup.cfg +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/setup.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/__wrapt__.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/_wrappers.c +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/arguments.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/caching.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/decorators.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/doc.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/exceptions.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/importer.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/patches.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/signature.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/synchronization.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/weakrefs.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt/wrappers.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt-stubs/__init__.pyi +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt.egg-info/SOURCES.txt +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt.egg-info/dependency_links.txt +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt.egg-info/not-zip-safe +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt.egg-info/requires.txt +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/src/wrapt.egg-info/top_level.txt +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/conftest.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/compat.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/module1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/module2.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_adapter.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_adapter_annotations.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_adapter_kwonly.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_annotations.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_attribute_wrapper.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_callable_binding_no_args.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_callable_object_proxy.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_class.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_class_mro_entries.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_copy.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_decorator_state.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_decorators.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_deferred_patching.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_descriptor_get_class_access.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_descriptors.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_enabled_bool_error.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_entry_points.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_find_wrapper.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_formatargspec.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_function.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_function_wrapper.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_inheritance.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_inner_classmethod.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_inner_staticmethod.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_inplace_operators.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_instancemethod.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_lru_cache.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_memoize.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_missing_sentinel.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_monkey_patching.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_nested_function.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_object_proxy.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_object_proxy_hook.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_object_proxy_self_dict.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_object_proxy_type_checks.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_outer_classmethod.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_outer_staticmethod.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_pickle.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_post_import_hooks.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_proxy_doc_descriptor.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_proxy_new_arguments.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_proxy_operands.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_pyerr_clear_propagation.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_resolve_path.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_runtime_type_hints.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_scoped_function_wrapper.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_synchronized_async.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_synchronized_lock.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_synchronized_markers.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_transient_function_wrapper.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_type_module_attribute.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_uninitialized_wrapper.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_unwrap_object.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_update_attributes.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_weak_function_proxy.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_with_doc.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_with_signature.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/core/test_wrapper_chain.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_auto_object_proxy_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_auto_object_proxy_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_decorator_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_decorator_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t2.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t2.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t3.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t3.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t4.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t4.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t5.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t5.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t6.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t6.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t7.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t7.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t8.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_cls_t8.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t2.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t2.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t3.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t3.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t4.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t4.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t5.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t5.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t6.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t6.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t7.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_function_wrapper_fn_t7.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_object_proxy_arithmetic_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_object_proxy_arithmetic_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_object_proxy_container_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_object_proxy_container_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_object_proxy_context_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_object_proxy_context_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_partial_callable_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_partial_callable_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_patch_function_wrapper_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_patch_function_wrapper_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_patching_primitives_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_patching_primitives_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_post_import_hooks_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_post_import_hooks_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_proxy_new_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_proxy_new_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_synchronized_lock_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_synchronized_lock_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_transient_function_wrapper_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_transient_function_wrapper_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_weak_function_proxy_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_weak_function_proxy_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_with_doc_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_with_doc_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t1.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t1.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t2.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t2.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t3.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t3.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t4.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t4.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t5.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t5.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t6.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t6.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t7.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t7.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t8.out +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/mypy/mypy_wrap_function_wrapper_t8.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/stress/runner.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/stress/stress_function_wrapper_call.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/stress/stress_init_reinit.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/stress/stress_inplace_ops.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/stress/stress_read_during_mutate.py +0 -0
- {wrapt-2.5.1.dev1 → wrapt-2.5.2}/tests/stress/stress_set_wrapped.py +0 -0
|
@@ -101,7 +101,14 @@ class AutoObjectProxy(BaseObjectProxy):
|
|
|
101
101
|
|
|
102
102
|
namespace = {}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
# Special methods are only ever looked up on the type of the wrapped
|
|
105
|
+
# object, never on the instance itself, so the special methods to add
|
|
106
|
+
# are determined from dir() of the type of the wrapped object. For a
|
|
107
|
+
# class the type is its metaclass, as the special methods a class
|
|
108
|
+
# defines in its body apply to its instances, not to the class
|
|
109
|
+
# itself.
|
|
110
|
+
|
|
111
|
+
wrapped_attrs = dir(type(wrapped))
|
|
105
112
|
class_attrs = set(dir(cls))
|
|
106
113
|
|
|
107
114
|
if callable(wrapped) and "__call__" not in class_attrs:
|
|
@@ -162,73 +169,79 @@ class AutoObjectProxy(BaseObjectProxy):
|
|
|
162
169
|
cls = type(self)
|
|
163
170
|
class_attrs = set(dir(cls))
|
|
164
171
|
|
|
172
|
+
# As for __new__() above, special methods are only ever looked up on
|
|
173
|
+
# the type of the wrapped object, never on the instance itself, so
|
|
174
|
+
# check for them on the type of the wrapped object.
|
|
175
|
+
|
|
176
|
+
wrapped_type = type(self.__wrapped__)
|
|
177
|
+
|
|
165
178
|
if callable(self.__wrapped__):
|
|
166
179
|
if "__call__" not in class_attrs:
|
|
167
180
|
cls.__call__ = __wrapper_call__
|
|
168
181
|
elif getattr(cls, "__call__", None) is __wrapper_call__:
|
|
169
182
|
delattr(cls, "__call__")
|
|
170
183
|
|
|
171
|
-
if hasattr(
|
|
184
|
+
if hasattr(wrapped_type, "__iter__"):
|
|
172
185
|
if "__iter__" not in class_attrs:
|
|
173
186
|
cls.__iter__ = __wrapper_iter__
|
|
174
187
|
elif getattr(cls, "__iter__", None) is __wrapper_iter__:
|
|
175
188
|
delattr(cls, "__iter__")
|
|
176
189
|
|
|
177
|
-
if hasattr(
|
|
190
|
+
if hasattr(wrapped_type, "__next__"):
|
|
178
191
|
if "__next__" not in class_attrs:
|
|
179
192
|
cls.__next__ = __wrapper_next__
|
|
180
193
|
elif getattr(cls, "__next__", None) is __wrapper_next__:
|
|
181
194
|
delattr(cls, "__next__")
|
|
182
195
|
|
|
183
|
-
if hasattr(
|
|
196
|
+
if hasattr(wrapped_type, "__aiter__"):
|
|
184
197
|
if "__aiter__" not in class_attrs:
|
|
185
198
|
cls.__aiter__ = __wrapper_aiter__
|
|
186
199
|
elif getattr(cls, "__aiter__", None) is __wrapper_aiter__:
|
|
187
200
|
delattr(cls, "__aiter__")
|
|
188
201
|
|
|
189
|
-
if hasattr(
|
|
202
|
+
if hasattr(wrapped_type, "__anext__"):
|
|
190
203
|
if "__anext__" not in class_attrs:
|
|
191
204
|
cls.__anext__ = __wrapper_anext__
|
|
192
205
|
elif getattr(cls, "__anext__", None) is __wrapper_anext__:
|
|
193
206
|
delattr(cls, "__anext__")
|
|
194
207
|
|
|
195
|
-
if hasattr(
|
|
208
|
+
if hasattr(wrapped_type, "__length_hint__"):
|
|
196
209
|
if "__length_hint__" not in class_attrs:
|
|
197
210
|
cls.__length_hint__ = __wrapper_length_hint__
|
|
198
211
|
elif getattr(cls, "__length_hint__", None) is __wrapper_length_hint__:
|
|
199
212
|
delattr(cls, "__length_hint__")
|
|
200
213
|
|
|
201
|
-
if hasattr(
|
|
214
|
+
if hasattr(wrapped_type, "__fspath__"):
|
|
202
215
|
if "__fspath__" not in class_attrs:
|
|
203
216
|
cls.__fspath__ = __wrapper_fspath__
|
|
204
217
|
elif getattr(cls, "__fspath__", None) is __wrapper_fspath__:
|
|
205
218
|
delattr(cls, "__fspath__")
|
|
206
219
|
|
|
207
|
-
if hasattr(
|
|
220
|
+
if hasattr(wrapped_type, "__await__"):
|
|
208
221
|
if "__await__" not in class_attrs:
|
|
209
222
|
cls.__await__ = __wrapper_await__
|
|
210
223
|
elif getattr(cls, "__await__", None) is __wrapper_await__:
|
|
211
224
|
delattr(cls, "__await__")
|
|
212
225
|
|
|
213
|
-
if hasattr(
|
|
226
|
+
if hasattr(wrapped_type, "__get__"):
|
|
214
227
|
if "__get__" not in class_attrs:
|
|
215
228
|
cls.__get__ = __wrapper_get__
|
|
216
229
|
elif getattr(cls, "__get__", None) is __wrapper_get__:
|
|
217
230
|
delattr(cls, "__get__")
|
|
218
231
|
|
|
219
|
-
if hasattr(
|
|
232
|
+
if hasattr(wrapped_type, "__set__"):
|
|
220
233
|
if "__set__" not in class_attrs:
|
|
221
234
|
cls.__set__ = __wrapper_set__
|
|
222
235
|
elif getattr(cls, "__set__", None) is __wrapper_set__:
|
|
223
236
|
delattr(cls, "__set__")
|
|
224
237
|
|
|
225
|
-
if hasattr(
|
|
238
|
+
if hasattr(wrapped_type, "__delete__"):
|
|
226
239
|
if "__delete__" not in class_attrs:
|
|
227
240
|
cls.__delete__ = __wrapper_delete__
|
|
228
241
|
elif getattr(cls, "__delete__", None) is __wrapper_delete__:
|
|
229
242
|
delattr(cls, "__delete__")
|
|
230
243
|
|
|
231
|
-
if hasattr(
|
|
244
|
+
if hasattr(wrapped_type, "__set_name__"):
|
|
232
245
|
if "__set_name__" not in class_attrs:
|
|
233
246
|
cls.__set_name__ = __wrapper_set_name__
|
|
234
247
|
elif getattr(cls, "__set_name__", None) is __wrapper_set_name__:
|
|
@@ -255,6 +255,152 @@ class TestAutoObjectProxy(unittest.TestCase):
|
|
|
255
255
|
del owner.attr
|
|
256
256
|
self.assertRaises(AttributeError, lambda: owner.attr)
|
|
257
257
|
|
|
258
|
+
def test_instance_attributes_are_not_special_methods(self):
|
|
259
|
+
# Special methods are only ever looked up on the type of an object,
|
|
260
|
+
# never on the instance itself. Instance attributes which shadow the
|
|
261
|
+
# dunder names therefore do not make the wrapped object iterable, or
|
|
262
|
+
# an iterator, and a proxy for the wrapped object must not act as
|
|
263
|
+
# iterable or an iterator either.
|
|
264
|
+
|
|
265
|
+
import collections.abc
|
|
266
|
+
|
|
267
|
+
class Wrapped:
|
|
268
|
+
pass
|
|
269
|
+
|
|
270
|
+
instance = Wrapped()
|
|
271
|
+
instance.__iter__ = lambda: iter([1, 2, 3])
|
|
272
|
+
instance.__next__ = lambda: 42
|
|
273
|
+
|
|
274
|
+
self.assertNotIsInstance(instance, collections.abc.Iterable)
|
|
275
|
+
self.assertRaises(TypeError, iter, instance)
|
|
276
|
+
self.assertRaises(TypeError, next, instance)
|
|
277
|
+
|
|
278
|
+
proxy = wrapt.AutoObjectProxy(instance)
|
|
279
|
+
|
|
280
|
+
# Note that iter() on the proxy does not itself raise TypeError, as
|
|
281
|
+
# iteration falls back to the __getitem__() sequence protocol, which
|
|
282
|
+
# wrapt.BaseObjectProxy always defines. Consuming the iterator still
|
|
283
|
+
# fails though, as the wrapped instance is not subscriptable.
|
|
284
|
+
|
|
285
|
+
self.assertNotIsInstance(proxy, collections.abc.Iterable)
|
|
286
|
+
self.assertRaises(TypeError, list, proxy)
|
|
287
|
+
self.assertRaises(TypeError, next, proxy)
|
|
288
|
+
|
|
289
|
+
def test_instance_attributes_are_not_awaitable(self):
|
|
290
|
+
# An instance attribute named __await__ does not make the wrapped
|
|
291
|
+
# object awaitable, so a proxy for the wrapped object must not be
|
|
292
|
+
# awaitable either.
|
|
293
|
+
|
|
294
|
+
import inspect
|
|
295
|
+
|
|
296
|
+
class Wrapped:
|
|
297
|
+
pass
|
|
298
|
+
|
|
299
|
+
instance = Wrapped()
|
|
300
|
+
instance.__await__ = lambda: iter(())
|
|
301
|
+
|
|
302
|
+
self.assertFalse(inspect.isawaitable(instance))
|
|
303
|
+
|
|
304
|
+
proxy = wrapt.AutoObjectProxy(instance)
|
|
305
|
+
|
|
306
|
+
self.assertFalse(inspect.isawaitable(proxy))
|
|
307
|
+
|
|
308
|
+
def test_instance_dir_does_not_hide_special_methods(self):
|
|
309
|
+
# The __dir__() method of an instance is not required to report the
|
|
310
|
+
# special methods defined on the type of the instance, so the
|
|
311
|
+
# special methods of the wrapped object can not be determined from
|
|
312
|
+
# dir() of the wrapped object itself.
|
|
313
|
+
|
|
314
|
+
class Wrapped:
|
|
315
|
+
def __iter__(self):
|
|
316
|
+
return iter([1, 2, 3])
|
|
317
|
+
|
|
318
|
+
def __dir__(self):
|
|
319
|
+
return []
|
|
320
|
+
|
|
321
|
+
instance = Wrapped()
|
|
322
|
+
|
|
323
|
+
self.assertEqual(list(instance), [1, 2, 3])
|
|
324
|
+
|
|
325
|
+
proxy = wrapt.AutoObjectProxy(instance)
|
|
326
|
+
|
|
327
|
+
self.assertEqual(list(proxy), [1, 2, 3])
|
|
328
|
+
|
|
329
|
+
def test_wrapped_class_is_not_descriptor(self):
|
|
330
|
+
class Descriptor:
|
|
331
|
+
def __get__(self, instance, owner=None):
|
|
332
|
+
return 42
|
|
333
|
+
|
|
334
|
+
def __set__(self, instance, value):
|
|
335
|
+
pass
|
|
336
|
+
|
|
337
|
+
def __delete__(self, instance):
|
|
338
|
+
pass
|
|
339
|
+
|
|
340
|
+
def __set_name__(self, owner, name):
|
|
341
|
+
pass
|
|
342
|
+
|
|
343
|
+
# Only instances of the class are descriptors, not the class itself,
|
|
344
|
+
# so a proxy for the class stored in a class body must not act as a
|
|
345
|
+
# descriptor.
|
|
346
|
+
|
|
347
|
+
class Owner:
|
|
348
|
+
attr = wrapt.AutoObjectProxy(Descriptor)
|
|
349
|
+
|
|
350
|
+
owner = Owner()
|
|
351
|
+
|
|
352
|
+
self.assertIs(Owner.attr.__wrapped__, Descriptor)
|
|
353
|
+
self.assertIs(owner.attr.__wrapped__, Descriptor)
|
|
354
|
+
|
|
355
|
+
owner.attr = 100
|
|
356
|
+
self.assertEqual(owner.attr, 100)
|
|
357
|
+
|
|
358
|
+
del owner.attr
|
|
359
|
+
self.assertIs(owner.attr.__wrapped__, Descriptor)
|
|
360
|
+
|
|
361
|
+
def test_wrapped_class_is_not_awaitable_or_iterable(self):
|
|
362
|
+
import collections.abc
|
|
363
|
+
import inspect
|
|
364
|
+
|
|
365
|
+
class Awaitable:
|
|
366
|
+
def __await__(self):
|
|
367
|
+
yield
|
|
368
|
+
return 42
|
|
369
|
+
|
|
370
|
+
class Iterable:
|
|
371
|
+
def __iter__(self):
|
|
372
|
+
return iter([1, 2, 3])
|
|
373
|
+
|
|
374
|
+
# The special methods the classes define are for their instances, not
|
|
375
|
+
# for the classes themselves, so the classes are not awaitable or
|
|
376
|
+
# iterable, and proxies for the classes must not be either.
|
|
377
|
+
|
|
378
|
+
self.assertFalse(inspect.isawaitable(Awaitable))
|
|
379
|
+
self.assertNotIsInstance(Iterable, collections.abc.Iterable)
|
|
380
|
+
|
|
381
|
+
self.assertFalse(inspect.isawaitable(wrapt.AutoObjectProxy(Awaitable)))
|
|
382
|
+
self.assertNotIsInstance(
|
|
383
|
+
wrapt.AutoObjectProxy(Iterable), collections.abc.Iterable
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
def test_wrapped_class_metaclass_iter(self):
|
|
387
|
+
class Meta(type):
|
|
388
|
+
def __iter__(cls):
|
|
389
|
+
return iter([1, 2, 3])
|
|
390
|
+
|
|
391
|
+
class Iterable(metaclass=Meta):
|
|
392
|
+
pass
|
|
393
|
+
|
|
394
|
+
# A class is iterated using the __iter__() defined by its metaclass,
|
|
395
|
+
# as that is the type of the class, so a proxy for the class must be
|
|
396
|
+
# iterable in the same way.
|
|
397
|
+
|
|
398
|
+
self.assertEqual(list(Iterable), [1, 2, 3])
|
|
399
|
+
|
|
400
|
+
proxy = wrapt.AutoObjectProxy(Iterable)
|
|
401
|
+
|
|
402
|
+
self.assertEqual(list(proxy), [1, 2, 3])
|
|
403
|
+
|
|
258
404
|
|
|
259
405
|
class TestAutoObjectProxyReassignment(unittest.TestCase):
|
|
260
406
|
|
|
@@ -499,3 +645,81 @@ class TestAutoObjectProxyReassignment(unittest.TestCase):
|
|
|
499
645
|
self.assertTrue(hasattr(proxy, "__set_name__"))
|
|
500
646
|
proxy.__wrapped__ = object()
|
|
501
647
|
self.assertFalse(hasattr(proxy, "__set_name__"))
|
|
648
|
+
|
|
649
|
+
def test_instance_attributes_are_not_special_methods_on_reassignment(self):
|
|
650
|
+
# Special methods are only ever looked up on the type of an object,
|
|
651
|
+
# never on the instance itself, so instance attributes which shadow
|
|
652
|
+
# the dunder names must not result in the proxy acting as iterable or
|
|
653
|
+
# an iterator when __wrapped__ is reassigned.
|
|
654
|
+
|
|
655
|
+
import collections.abc
|
|
656
|
+
|
|
657
|
+
class Wrapped:
|
|
658
|
+
pass
|
|
659
|
+
|
|
660
|
+
instance = Wrapped()
|
|
661
|
+
instance.__iter__ = lambda: iter([1, 2, 3])
|
|
662
|
+
instance.__next__ = lambda: 42
|
|
663
|
+
|
|
664
|
+
proxy = wrapt.AutoObjectProxy(object())
|
|
665
|
+
|
|
666
|
+
proxy.__wrapped__ = instance
|
|
667
|
+
|
|
668
|
+
self.assertNotIsInstance(proxy, collections.abc.Iterable)
|
|
669
|
+
self.assertRaises(TypeError, list, proxy)
|
|
670
|
+
self.assertRaises(TypeError, next, proxy)
|
|
671
|
+
|
|
672
|
+
def test_instance_attributes_are_not_awaitable_on_reassignment(self):
|
|
673
|
+
# An instance attribute named __await__ must not result in the proxy
|
|
674
|
+
# being reported as awaitable when __wrapped__ is reassigned.
|
|
675
|
+
|
|
676
|
+
import inspect
|
|
677
|
+
|
|
678
|
+
class Wrapped:
|
|
679
|
+
pass
|
|
680
|
+
|
|
681
|
+
instance = Wrapped()
|
|
682
|
+
instance.__await__ = lambda: iter(())
|
|
683
|
+
|
|
684
|
+
proxy = wrapt.AutoObjectProxy(object())
|
|
685
|
+
|
|
686
|
+
proxy.__wrapped__ = instance
|
|
687
|
+
|
|
688
|
+
self.assertFalse(inspect.isawaitable(proxy))
|
|
689
|
+
|
|
690
|
+
def test_wrapped_class_is_not_descriptor_on_reassignment(self):
|
|
691
|
+
class Descriptor:
|
|
692
|
+
def __get__(self, instance, owner=None):
|
|
693
|
+
return 42
|
|
694
|
+
|
|
695
|
+
def __set_name__(self, owner, name):
|
|
696
|
+
pass
|
|
697
|
+
|
|
698
|
+
# Only instances of the class are descriptors, not the class itself,
|
|
699
|
+
# so the proxy must not act as a descriptor when __wrapped__ is
|
|
700
|
+
# reassigned to the class.
|
|
701
|
+
|
|
702
|
+
proxy = wrapt.AutoObjectProxy(object())
|
|
703
|
+
proxy.__wrapped__ = Descriptor
|
|
704
|
+
|
|
705
|
+
class Owner:
|
|
706
|
+
attr = proxy
|
|
707
|
+
|
|
708
|
+
self.assertIs(Owner().attr, proxy)
|
|
709
|
+
|
|
710
|
+
def test_wrapped_class_metaclass_iter_on_reassignment(self):
|
|
711
|
+
class Meta(type):
|
|
712
|
+
def __iter__(cls):
|
|
713
|
+
return iter([1, 2, 3])
|
|
714
|
+
|
|
715
|
+
class Iterable(metaclass=Meta):
|
|
716
|
+
pass
|
|
717
|
+
|
|
718
|
+
# A class is iterated using the __iter__() defined by its metaclass,
|
|
719
|
+
# as that is the type of the class, so iteration of the proxy must
|
|
720
|
+
# still work when __wrapped__ is reassigned to the class.
|
|
721
|
+
|
|
722
|
+
proxy = wrapt.AutoObjectProxy(object())
|
|
723
|
+
proxy.__wrapped__ = Iterable
|
|
724
|
+
|
|
725
|
+
self.assertEqual(list(proxy), [1, 2, 3])
|
|
@@ -167,3 +167,46 @@ class TestLazyObjectProxy(unittest.TestCase):
|
|
|
167
167
|
self.assertEqual(status["created"], 1)
|
|
168
168
|
self.assertEqual(os.fspath(proxy), "example.txt")
|
|
169
169
|
self.assertEqual(status["created"], 1)
|
|
170
|
+
|
|
171
|
+
def test_lazy_class_is_not_descriptor(self):
|
|
172
|
+
# Only instances of the class are descriptors, not the class itself,
|
|
173
|
+
# so a lazy proxy whose factory returns the class must not act as a
|
|
174
|
+
# descriptor when stored in a class body.
|
|
175
|
+
|
|
176
|
+
class Descriptor:
|
|
177
|
+
def __get__(self, instance, owner=None):
|
|
178
|
+
return 42
|
|
179
|
+
|
|
180
|
+
def __set_name__(self, owner, name):
|
|
181
|
+
pass
|
|
182
|
+
|
|
183
|
+
proxy = wrapt.LazyObjectProxy(lambda: Descriptor)
|
|
184
|
+
|
|
185
|
+
self.assertIs(proxy.__wrapped__, Descriptor)
|
|
186
|
+
|
|
187
|
+
class Owner:
|
|
188
|
+
attr = proxy
|
|
189
|
+
|
|
190
|
+
self.assertIs(Owner().attr, proxy)
|
|
191
|
+
|
|
192
|
+
def test_lazy_instance_attributes_are_not_special_methods(self):
|
|
193
|
+
# Special methods are only ever looked up on the type of an object,
|
|
194
|
+
# never on the instance itself, so instance attributes which shadow
|
|
195
|
+
# the dunder names must not result in the proxy being reported as
|
|
196
|
+
# iterable when the factory returns an instance carrying them.
|
|
197
|
+
|
|
198
|
+
import collections.abc
|
|
199
|
+
|
|
200
|
+
class Wrapped:
|
|
201
|
+
pass
|
|
202
|
+
|
|
203
|
+
def factory():
|
|
204
|
+
instance = Wrapped()
|
|
205
|
+
instance.__iter__ = lambda: iter([1, 2, 3])
|
|
206
|
+
return instance
|
|
207
|
+
|
|
208
|
+
proxy = wrapt.LazyObjectProxy(factory)
|
|
209
|
+
|
|
210
|
+
self.assertIs(proxy.__wrapped__.__class__, Wrapped)
|
|
211
|
+
|
|
212
|
+
self.assertNotIsInstance(proxy, collections.abc.Iterable)
|
|
@@ -13,7 +13,6 @@ python =
|
|
|
13
13
|
3.13: py313, py313-without-extensions, py313-install-extensions, py313-disable-extensions
|
|
14
14
|
3.14: py314, py314-without-extensions, py314-install-extensions, py314-disable-extensions
|
|
15
15
|
3.15-dev: py315, py315-without-extensions, py315-install-extensions, py315-disable-extensions
|
|
16
|
-
pypy-3.9: pypy-without-extensions
|
|
17
16
|
pypy-3.10: pypy-without-extensions
|
|
18
17
|
pypy-3.11: pypy-without-extensions
|
|
19
18
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|