Commits
Click on a commit to change the comparison rangeFix AttributeError when using Nuitka-compiled models
When using tortoise-orm with Nuitka-compiled Python code, the _get_comments
function fails with an AttributeError because inspect.getsourcefile() returns
None for compiled modules, and the code attempts to call .endswith() on None.
This error occurs in the following stack trace:
- _get_comments() calls inspect.getsource(cls)
- inspect.getsource() -> inspect.getsourcelines() -> inspect.findsource()
- inspect.findsourcefile() returns None for Nuitka-compiled modules
- inspect.findsource() tries to call filename.endswith(), causing AttributeError
The fix adds AttributeError to the exception handling in _get_comments(),
allowing the function to gracefully return an empty dict when source code
cannot be retrieved from compiled modules.
Fixes: AttributeError: 'NoneType' object has no attribute 'endswith' Add changelog entry and contributor credit
- Added changelog entry for Nuitka compilation fix in 0.26.0 section
- Added Qian Chen (@shkey) to contributors list