Skip to content

Not throwing TypeError if extend_enum is called without the required number of arguments #33

Description

@its-wizza

There is an undefined variable name undefined in _enum.py causing errors if there are not enough arguments given to extend_enum (might be in other cases too but haven't tested)

To recreate:

from aenum import Enum, extend_enum

class MyEnum(Enum, init="var1 var2"):
    pass

extend_enum(MyEnum, "NEW_MEMBER", "my_var1")

Output:

Traceback (most recent call last):
  ...
  File "...\aenum\_enum.py", line 2722, in extend_enum
    new_member.__init__(*args)
  File "...\aenum\_enum.py", line 2203, in __init__
    value = kwds.pop(name, undefined)
NameError: name 'undefined' is not defined

Relevant lines from __init__ of _enum.py:

2200        if len(args) < len(_auto_init_):
2201            remaining_args = _auto_init_[len(args):]
2202            for name in remaining_args:
2203                value = kwds.pop(name, undefined)
2204                if value is undefined:
2205                    raise TypeError('missing value for: %r' % (name, ))
2206                setattr(self, name, value)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions