Skip to content

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

@fsahmad

Description

@fsahmad

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions