@@ -226,6 +226,23 @@ def test_property_set_name_incorrect_args(self):
226226 ):
227227 p .__set_name__ (* ([0 ] * i ))
228228
229+ def test_property_setname_on_property_subclass (self ):
230+ # https://github.com/python/cpython/issues/100942
231+ # Copy was setting the name field without first
232+ # verifying that the copy was an actual property
233+ # instance. As a result, the code below was
234+ # causing a segfault.
235+
236+ class pro (property ):
237+ def __new__ (typ , * args , ** kwargs ):
238+ return "abcdef"
239+
240+ class A :
241+ pass
242+
243+ p = property .__new__ (pro )
244+ p .__set_name__ (A , 1 )
245+ np = p .getter (lambda self : 1 )
229246
230247# Issue 5890: subclasses of property do not preserve method __doc__ strings
231248class PropertySub (property ):
@@ -341,43 +358,35 @@ def _format_exc_msg(self, msg):
341358 def setUpClass (cls ):
342359 cls .obj = cls .cls ()
343360
361+ # TODO: RUSTPYTHON
362+ @unittest .expectedFailure
344363 def test_get_property (self ):
345- with self .assertRaisesRegex (AttributeError , self ._format_exc_msg ("unreadable attribute " )):
364+ with self .assertRaisesRegex (AttributeError , self ._format_exc_msg ("has no getter " )):
346365 self .obj .foo
347366
367+ # TODO: RUSTPYTHON
368+ @unittest .expectedFailure
348369 def test_set_property (self ):
349- with self .assertRaisesRegex (AttributeError , self ._format_exc_msg ("can't set attribute " )):
370+ with self .assertRaisesRegex (AttributeError , self ._format_exc_msg ("has no setter " )):
350371 self .obj .foo = None
351372
373+ # TODO: RUSTPYTHON
374+ @unittest .expectedFailure
352375 def test_del_property (self ):
353- with self .assertRaisesRegex (AttributeError , self ._format_exc_msg ("can't delete attribute " )):
376+ with self .assertRaisesRegex (AttributeError , self ._format_exc_msg ("has no deleter " )):
354377 del self .obj .foo
355378
356379
357380class PropertyUnreachableAttributeWithName (_PropertyUnreachableAttribute , unittest .TestCase ):
358- msg_format = "^{} 'foo'$"
381+ msg_format = r"^property 'foo' of 'PropertyUnreachableAttributeWithName\.cls' object {} $"
359382
360383 class cls :
361384 foo = property ()
362385
363- # TODO: RUSTPYTHON
364- @unittest .expectedFailure
365- def test_get_property (self ): # TODO: RUSTPYTHON; remove this function when the test is fixed
366- super ().test_get_property ()
367-
368- # TODO: RUSTPYTHON
369- @unittest .expectedFailure
370- def test_set_property (self ): # TODO: RUSTPYTHON; remove this function when the test is fixed
371- super ().test_get_property ()
372-
373- # TODO: RUSTPYTHON
374- @unittest .expectedFailure
375- def test_del_property (self ): # TODO: RUSTPYTHON; remove this function when the test is fixed
376- super ().test_get_property ()
377386
378387
379388class PropertyUnreachableAttributeNoName (_PropertyUnreachableAttribute , unittest .TestCase ):
380- msg_format = "^ {}$"
389+ msg_format = r"^property of 'PropertyUnreachableAttributeNoName\.cls' object {}$"
381390
382391 class cls :
383392 pass
0 commit comments