mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-100942: Fix incorrect cast in property_copy(). (#100965)
This commit is contained in:
parent
b511d3512b
commit
94fc7706b7
3 changed files with 22 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue