Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
its-wizza opened this issue Jul 11, 2023 · 0 comments

Comments

@its-wizza
Copy link

its-wizza commented Jul 11, 2023

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant