Skip to content

Commit bd176fe

Browse files
committed
Add irbuild glue test for property setter, remove stale comment
1 parent dcb31e1 commit bd176fe

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

mypyc/test-data/irbuild-glue-methods.test

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,59 @@ class EE(E):
453453
main:7: error: An argument with type "i64" cannot be given a default value in a method override
454454
main:13: error: Incompatible argument type "i64" (base class has type "int")
455455
main:18: error: Incompatible argument type "int" (base class has type "i64")
456+
457+
[case testPropertySetterShadowGlue]
458+
import mypy_extensions
459+
460+
@mypy_extensions.mypyc_attr(allow_interpreted_subclasses=True)
461+
class Base:
462+
_x: str = ""
463+
464+
@property
465+
def x(self) -> str:
466+
return self._x
467+
468+
@x.setter
469+
def x(self, v: str) -> None:
470+
self._x = v
471+
[out]
472+
def Base.x(self):
473+
self :: __main__.Base
474+
r0 :: str
475+
L0:
476+
r0 = self._x
477+
return r0
478+
def Base.x__Base_glue(__mypyc_self__):
479+
__mypyc_self__ :: __main__.Base
480+
r0 :: str
481+
r1 :: object
482+
r2 :: str
483+
L0:
484+
r0 = 'x'
485+
r1 = CPyObject_GetAttr(__mypyc_self__, r0)
486+
r2 = cast(str, r1)
487+
return r2
488+
def Base.__mypyc_setter__x(self, v):
489+
self :: __main__.Base
490+
v :: str
491+
r0 :: bool
492+
L0:
493+
self._x = v; r0 = is_error
494+
return 1
495+
def Base.__mypyc_setter__x__Base_glue(self, v):
496+
self :: __main__.Base
497+
v, r0 :: str
498+
r1 :: i32
499+
r2 :: bit
500+
L0:
501+
r0 = 'x'
502+
r1 = PyObject_SetAttr(self, r0, v)
503+
r2 = r1 >= 0 :: signed
504+
return 1
505+
def Base.__mypyc_defaults_setup(__mypyc_self__):
506+
__mypyc_self__ :: __main__.Base
507+
r0 :: str
508+
L0:
509+
r0 = ''
510+
__mypyc_self__._x = r0
511+
return 1

mypyc/test-data/run-classes.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5776,8 +5776,6 @@ assert c.value() == 42
57765776
assert c.derived() == 42
57775777

57785778
[case testPropertyShadowVtableGlue]
5779-
# The setter's shadow glue overwrites the getter's (both keyed by fdef.name),
5780-
# misaligning subsequent vtable entries -> segfault on interpreted subclasses.
57815779
from typing import List
57825780
import mypy_extensions
57835781

0 commit comments

Comments
 (0)