@@ -226,6 +226,23 @@ def test_property_set_name_incorrect_args(self):
226
226
):
227
227
p .__set_name__ (* ([0 ] * i ))
228
228
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 )
229
246
230
247
# Issue 5890: subclasses of property do not preserve method __doc__ strings
231
248
class PropertySub (property ):
@@ -341,43 +358,35 @@ def _format_exc_msg(self, msg):
341
358
def setUpClass (cls ):
342
359
cls .obj = cls .cls ()
343
360
361
+ # TODO: RUSTPYTHON
362
+ @unittest .expectedFailure
344
363
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 " )):
346
365
self .obj .foo
347
366
367
+ # TODO: RUSTPYTHON
368
+ @unittest .expectedFailure
348
369
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 " )):
350
371
self .obj .foo = None
351
372
373
+ # TODO: RUSTPYTHON
374
+ @unittest .expectedFailure
352
375
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 " )):
354
377
del self .obj .foo
355
378
356
379
357
380
class PropertyUnreachableAttributeWithName (_PropertyUnreachableAttribute , unittest .TestCase ):
358
- msg_format = "^{} 'foo'$"
381
+ msg_format = r"^property 'foo' of 'PropertyUnreachableAttributeWithName\.cls' object {} $"
359
382
360
383
class cls :
361
384
foo = property ()
362
385
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 ()
377
386
378
387
379
388
class PropertyUnreachableAttributeNoName (_PropertyUnreachableAttribute , unittest .TestCase ):
380
- msg_format = "^ {}$"
389
+ msg_format = r"^property of 'PropertyUnreachableAttributeNoName\.cls' object {}$"
381
390
382
391
class cls :
383
392
pass
0 commit comments