What's wrong
PythonGenerator.GeneratePropertyDeclaration (Coder/Languages/PythonGenerator.cs:125-137) writes @{name}.setter whenever CanWrite is true. That decorator needs a name property object to already exist in the class body, and one only exists if the @property getter was written first, which happens only when CanRead is true. For a write-only property, the decorator refers to a name that was never defined.
Repro
ClassDeclaration cls = new("Sink");
PropertyDeclaration p = new("level", "int") { HasGetter = false, HasSetter = true };
p.SetterBody.Add(new ExpressionStatement(new CallExpression("record")));
cls.Members.Add(p);
new PythonGenerator().Generate(cls);
Output:
class Sink:
@level.setter
def level(self, value: int) -> None:
record()
Running it with python3 fails when the class is defined: NameError: name 'level' is not defined. The other targets all emit a valid write-only property: C# set { ... }, JavaScript set level(value), and a set_level function for C, C++, Go and Rust.
Suggested fix / acceptance criteria
When !CanRead, emit a setter-only property without the decorator form:
def _set_level(self, value: int) -> None:
record()
level = property(fset=_set_level)
Add a Python test with HasGetter = false. No existing test covers that case.
What's wrong
PythonGenerator.GeneratePropertyDeclaration(Coder/Languages/PythonGenerator.cs:125-137) writes@{name}.setterwheneverCanWriteis true. That decorator needs anameproperty object to already exist in the class body, and one only exists if the@propertygetter was written first, which happens only whenCanReadis true. For a write-only property, the decorator refers to a name that was never defined.Repro
Output:
Running it with
python3fails when the class is defined:NameError: name 'level' is not defined. The other targets all emit a valid write-only property: C#set { ... }, JavaScriptset level(value), and aset_levelfunction for C, C++, Go and Rust.Suggested fix / acceptance criteria
When
!CanRead, emit a setter-only property without the decorator form:Add a Python test with
HasGetter = false. No existing test covers that case.