diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-08-29 08:27:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-29 08:27:42 (GMT) |
commit | 0dac68f1e593c11612ed54af9edb865d398f3b05 (patch) | |
tree | 0697b0f9543d4b65feaf75b3335c2fb85481e4d1 /Lib | |
parent | 84125fed2a45a9e454d7e870d8bbaf6ece3d41e8 (diff) | |
download | cpython-0dac68f1e593c11612ed54af9edb865d398f3b05.zip cpython-0dac68f1e593c11612ed54af9edb865d398f3b05.tar.gz cpython-0dac68f1e593c11612ed54af9edb865d398f3b05.tar.bz2 |
bpo-36743: __get__ is sometimes called without the owner argument (#12992)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/_pyio.py | 2 | ||||
-rw-r--r-- | Lib/functools.py | 6 | ||||
-rw-r--r-- | Lib/unittest/mock.py | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 1b24ef9..0d3f974 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -283,7 +283,7 @@ except AttributeError: class DocDescriptor: """Helper for builtins.open.__doc__ """ - def __get__(self, obj, typ): + def __get__(self, obj, typ=None): return ( "open(file, mode='r', buffering=-1, encoding=None, " "errors=None, newline=None, closefd=True)\n\n" + diff --git a/Lib/functools.py b/Lib/functools.py index 9495fbe..f87d9c5 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -383,7 +383,7 @@ class partialmethod(object): _method._partialmethod = self return _method - def __get__(self, obj, cls): + def __get__(self, obj, cls=None): get = getattr(self.func, "__get__", None) result = None if get is not None: @@ -888,7 +888,7 @@ class singledispatchmethod: """ return self.dispatcher.register(cls, func=method) - def __get__(self, obj, cls): + def __get__(self, obj, cls=None): def _method(*args, **kwargs): method = self.dispatcher.dispatch(args[0].__class__) return method.__get__(obj, cls)(*args, **kwargs) @@ -926,7 +926,7 @@ class cached_property: f"({self.attrname!r} and {name!r})." ) - def __get__(self, instance, owner): + def __get__(self, instance, owner=None): if instance is None: return self if self.attrname is None: diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index c6771ce..89312f1 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -2804,7 +2804,7 @@ class PropertyMock(Mock): def _get_child_mock(self, /, **kwargs): return MagicMock(**kwargs) - def __get__(self, obj, obj_type): + def __get__(self, obj, obj_type=None): return self() def __set__(self, obj, val): self(val) |