Skip to content

LazyObject raises error in Nuitka binary when it converts to dict #12

Description

@anki-code

Hi!

If we convert Python code to the binary using Nuitka LazyObject raises error when it converts to dict.

Example (lazy.py):

from lazyasd import LazyObject

VAR = LazyObject(lambda: {"answer": 42}, globals(), 'VAR')

print(type(VAR), dict(VAR))
print(type(VAR), VAR)

Run:

pip install lazyasd nuitka

# Works perfect in Python
python lazy.py
# <class 'lazyasd.LazyObject'> {'answer': 42}
# <class 'dict'> {'answer': 42}

# Not working in Nuitka
python -m nuitka lazy.py
./lazy.bin 
#Traceback (most recent call last):
#  File "/tmp/lazy.py", line 5, in <module>
#    print(type(VAR), dict(VAR))
#  File "/opt/miniconda/lib/python3.8/site-packages/lazyasd.py", line 64, in __getattribute__
#    obj = self._lazy_obj()
#  File "/opt/miniconda/lib/python3.8/site-packages/lazyasd.py", line 63, in __getattribute__
#    return super().__getattribute__(name)
#AttributeError: 'method-wrapper' object has no attribute '_lazy_obj'

Another use cases of LazyObject are look working (but require more testing).

More info:

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

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