diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-01-15 10:08:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-15 12:38:59 +0530 |
commit | b7b641a2ffaa0d370e73bed193b55aacb82f1069 (patch) | |
tree | 112ec953f84399ee8dd23a33a72c73f34781ab82 /Lib/test/test_property.py | |
parent | 78c9f39352a04e07ee4de7746c797ca79b5270d7 (diff) | |
download | cpython-git-b7b641a2ffaa0d370e73bed193b55aacb82f1069.tar.gz |
[3.10] GH-100942: Fix incorrect cast in property_copy(). (GH-100965). (#101009)
(cherry picked from commit 94fc7706b7bc3d57cdd6d15bf8e8c4499ae53a69)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_property.py')
-rw-r--r-- | Lib/test/test_property.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py index 7f3813fc8c..4cd4283d84 100644 --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -214,6 +214,23 @@ class PropertyTests(unittest.TestCase): ): p.__set_name__(*([0] * i)) + def test_property_setname_on_property_subclass(self): + # https://github.com/python/cpython/issues/100942 + # Copy was setting the name field without first + # verifying that the copy was an actual property + # instance. As a result, the code below was + # causing a segfault. + + class pro(property): + def __new__(typ, *args, **kwargs): + return "abcdef" + + class A: + pass + + p = property.__new__(pro) + p.__set_name__(A, 1) + np = p.getter(lambda self: 1) # Issue 5890: subclasses of property do not preserve method __doc__ strings class PropertySub(property): |