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

[Python 3.11] AttributeError: NoneType object has no attribute __name__ #2

Open
demberto opened this issue Oct 26, 2022 · 2 comments
Open
Labels
help wanted Extra attention is needed

Comments

@demberto
Copy link

Traceback:
    fastenum.enable()
.tox\py311\Lib\site-packages\fastenum\__init__.py:24: in enable
    Patch.enable_patches()
.tox\py311\Lib\site-packages\fastenum\parcher.py:154: in enable_patches
    patch.enable(check)
.tox\py311\Lib\site-packages\fastenum\parcher.py:110: in enable
    cls.__run_on_instance__(obj)
.tox\py311\Lib\site-packages\fastenum\patches.py:53: in __run_on_instance__
    instance.alias = f'_cls_attr_{instance.fget.__name__}'
E   AttributeError: 'NoneType' object has no attribute '__name__'
@demberto demberto changed the title [Python 3.11] AttributeError: 'NoneType' object has no attribute '__name__' [Python 3.11] AttributeError: NoneType object has no attribute __name__ Oct 26, 2022
@Bobronium
Copy link
Owner

Bobronium commented Oct 27, 2022

Enum has seen lots of changes in 3.11.

I'm not sure when I'll have time to update the project ensuring compatibility with all currently supported versions and 3.11.
Perhaps it can be simplified to support only 3.11 in a new version, but this is a lot of work as well.

A quick workaround would be to put this in fastenum\patches.py:53:

if instance.alias is None:
    return

With this change it works, but tests are still not compatible with 3.11 so I can't guarantee it won't break somewhere else.

In case you'd like to make a PR with 3.11 support, here's a checklist that comes to mind:

  • Tests work (this project includes its own unittests, as well as modified builtin CPython tests)
  • PatchedEnum is always faster than BuiltinEnum (use benchmark and feel free to add new testcases)
  • There are no breaking changes / differences in public API in patched enum
  • There are no warnings emited during enabling/disabling fastenum

@Bobronium Bobronium added the help wanted Extra attention is needed label Oct 27, 2022
@demberto
Copy link
Author

I could give it a go, but I am already wary about Python's enum implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants