aenum icon indicating copy to clipboard operation
aenum copied to clipboard

`aenum>=3.1.13` fails to import on PyPy3

Open joouha opened this issue 2 years ago • 1 comments

Hi,

I'm getting this NoneType releated error when using recent aenum releases with PyPy:

$ pypy3 -m pip install -qqq aenum==3.1.12 && pypy3 -c 'import aenum'

$ pypy3 -m pip install -qqq aenum==3.1.13 && pypy3 -c 'import aenum'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/josiah/.local/lib/pypy3.9/site-packages/aenum/__init__.py", line 7, in <module>
    from ._common import *
AttributeError: module 'aenum._common' has no attribute 'NoneType'

$ pypy3 -V
Python 3.9.16 (feeb267ead3e6771d3f2f49b83e1894839f64fb7, Feb 21 2023, 19:39:22)
[PyPy 7.3.11 with GCC 12.2.1 20230201]

It only occurs in PyPy, CPython is fine.

joouha avatar Jul 06 '23 08:07 joouha

This seems to be due to a slight difference in this implementation within _common

try:
    NoneType
except NameError:
    NoneType = type(None)

If the NoneType type is supported by the interpreter, like how it appears in PyPy, it doesn't add the NoneType as an attribute to _common to be imported. It causes an error when the NoneType is defined in the __all__ list but isn't defined.

I don't know enough about how it's used, but could it possibly be changed to

try:
    NoneType = NoneType
except NameError:
    NoneType = type(None)

or Simply

NoneType = type(None)

hutcheb avatar Nov 27 '24 07:11 hutcheb