summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorFurkan Onder <furkanonder@protonmail.com>2023-05-16 17:34:44 +0000
committerGitHub <noreply@github.com>2023-05-16 17:34:44 +0000
commit5e9f471e7db30893fb3f42681f17fdcdb70069ee (patch)
tree92504b6558a35c489cfd564cf0a8a72dc5301693 /Lib
parenta454a6651ba26ed623377dd01ed62a0a22afa8c7 (diff)
downloadcpython-git-5e9f471e7db30893fb3f42681f17fdcdb70069ee.tar.gz
gh-75367: Fix data descriptor detection in inspect.getattr_static (#104517)
Co-authored-by: Carl Meyer <carl@oddbird.net>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/inspect.py6
-rw-r--r--Lib/test/test_inspect.py3
2 files changed, 7 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index a64e85e4fd..63f5aa91d2 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1835,8 +1835,10 @@ def getattr_static(obj, attr, default=_sentinel):
klass_result = _check_class(klass, attr)
if instance_result is not _sentinel and klass_result is not _sentinel:
- if (_check_class(type(klass_result), '__get__') is not _sentinel and
- _check_class(type(klass_result), '__set__') is not _sentinel):
+ if _check_class(type(klass_result), "__get__") is not _sentinel and (
+ _check_class(type(klass_result), "__set__") is not _sentinel
+ or _check_class(type(klass_result), "__delete__") is not _sentinel
+ ):
return klass_result
if instance_result is not _sentinel:
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 364f75db90..0590e49d0e 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -2052,6 +2052,9 @@ class TestGetattrStatic(unittest.TestCase):
descriptor.__set__ = lambda s, i, v: None
self.assertEqual(inspect.getattr_static(foo, 'd'), Foo.__dict__['d'])
+ del descriptor.__set__
+ descriptor.__delete__ = lambda s, i, o: None
+ self.assertEqual(inspect.getattr_static(foo, 'd'), Foo.__dict__['d'])
def test_metaclass_with_descriptor(self):
class descriptor(object):