diff options
| author | Bert JW Regeer <bertjw@regeer.org> | 2015-02-07 12:57:11 -0700 |
|---|---|---|
| committer | Bert JW Regeer <bertjw@regeer.org> | 2015-02-07 13:08:13 -0700 |
| commit | c600ab6fe31e2ea95f1aea9f8c40ae585f6afe39 (patch) | |
| tree | 3a3a397bc0d4a002044da377413adf419ad25912 | |
| parent | c7c02f44492da19d848d66556c2c13b9c79ee7ee (diff) | |
| download | pyramid-c600ab6fe31e2ea95f1aea9f8c40ae585f6afe39.tar.gz pyramid-c600ab6fe31e2ea95f1aea9f8c40ae585f6afe39.tar.bz2 pyramid-c600ab6fe31e2ea95f1aea9f8c40ae585f6afe39.zip | |
Remove __providesBy__ attribute from being copied
This change reverts part of what
https://github.com/Pylons/pyramid/issues/1212 changed. We attempt to
copy information used by zope.interfaces to the new class to avoid
creating new objects that could possibly leak.
Unfortunately copying over __providedBy__ causes issues with the
sub-class after modification no longer implementing interfaces, for more
information see:
https://github.com/Pylons/pyramid/issues/1529#issuecomment-73373581
Once __providedBy__ is removed from the list, this is no longer the case
and the new class that is created in `_set_properties` properly report
that it implements the interfaces it used to implement before.
| -rw-r--r-- | pyramid/tests/test_request.py | 1 | ||||
| -rw-r--r-- | pyramid/util.py | 10 |
2 files changed, 5 insertions, 6 deletions
diff --git a/pyramid/tests/test_request.py b/pyramid/tests/test_request.py index 1a7b1a106..091454893 100644 --- a/pyramid/tests/test_request.py +++ b/pyramid/tests/test_request.py @@ -436,7 +436,6 @@ class Test_call_app_with_subpath_as_path_info(unittest.TestCase): self.assertEqual(request.environ['PATH_INFO'], '/' + encoded) class Test_subclassing_Request(unittest.TestCase): - def test_subclass(self): from pyramid.interfaces import IRequest from pyramid.request import Request diff --git a/pyramid/util.py b/pyramid/util.py index 18cef4602..7903326a5 100644 --- a/pyramid/util.py +++ b/pyramid/util.py @@ -87,10 +87,10 @@ class InstancePropertyMixin(object): if attrs: parent = self.__class__ cls = type(parent.__name__, (parent, object), attrs) - # We assign __provides__, __implemented__ and __providedBy__ below - # to prevent a memory leak that results from from the usage of this - # instance's eventual use in an adapter lookup. Adapter lookup - # results in ``zope.interface.implementedBy`` being called with the + # We assign __provides__ and __implemented__ below to prevent a + # memory leak that results from from the usage of this instance's + # eventual use in an adapter lookup. Adapter lookup results in + # ``zope.interface.implementedBy`` being called with the # newly-created class as an argument. Because the newly-created # class has no interface specification data of its own, lookup # causes new ClassProvides and Implements instances related to our @@ -99,7 +99,7 @@ class InstancePropertyMixin(object): # want this new class to behave exactly like it is the parent class # instead. See https://github.com/Pylons/pyramid/issues/1212 for # more information. - for name in ('__implemented__', '__providedBy__', '__provides__'): + for name in ('__implemented__', '__provides__'): # we assign these attributes conditionally to make it possible # to test this class in isolation without having any interfaces # attached to it |
