AutomaticComponentToolkit icon indicating copy to clipboard operation
AutomaticComponentToolkit copied to clipboard

[Python] SyntaxError when using "None" as a name (Python keyword)

Open fsahmad opened this issue 4 years ago • 0 comments

Python binding cannot be imported because of the following error when the reserved keyword "None" is used as a enum value:

SyntaxError: cannot assign to None

Encountered the problem when using "None" as the name for an enum value, but similar issues are bound to happen elsewhere. Example IDL to reproduce:

	<enum name="DisplayMode">
		<option name="None" value="0"/>
		<option name="Value" value="1"/>
		<option name="Name" value="2"/>
		<option name="Both" value="3"/>
	</enum>

Generated binding:

'''Definition of AttributeDisplayMode
'''
class AttributeDisplayMode(CTypesEnum):
    None = 0
    Value = 1
    Name = 2
    Both = 3

At the very least, ACT should report an error in this case so another name can be used. Alternatively, lower/uppercase could be used (none/NONE) to prevent collisions.

fsahmad avatar Jan 18 '21 14:01 fsahmad