Skip to content

[Fix] _LazyError reads name-mangled __data via unmangled literal → AttributeError (#3751) - #3767

Open
yushuosun wants to merge 1 commit into
nerfstudio-project:mainfrom
yushuosun:fix/lazyerror-name-mangling
Open

[Fix] _LazyError reads name-mangled __data via unmangled literal → AttributeError (#3751)#3767
yushuosun wants to merge 1 commit into
nerfstudio-project:mainfrom
yushuosun:fix/lazyerror-name-mangling

Conversation

@yushuosun

Copy link
Copy Markdown

Motivation

When an optional dependency such as tinycudann is not installed, touching the lazily-errored stand-in raises a confusing AttributeError: __data instead of the intended RuntimeError("Could not load package tinycudann.") (#3751 — e.g. neus-facto on SDFStudio data fails with _LazyError object has no attribute __data).

Root cause

In nerfstudio/utils/external.py, _LazyError and its inner LazyErrorObj store the payload as self.__data = data. Inside a class, self.__data is name-mangled to self._LazyError__data / self._LazyErrorObj__data. But the __call__/__getattr__ methods read it back via:

object.__getattribute__(self, "__data")

That string literal "__data" is not name-mangled, so the attribute does not exist — hence AttributeError instead of the helpful RuntimeError.

Modifications

nerfstudio/utils/external.py: store and read the payload under a consistent, non-mangled name _data (replace self.__data and the object.__getattribute__(self, "__data") lookups). This restores the intended "package not installed" error message.

Duplicate-check

_LazyError and its inner LazyErrorObj store self.__data, which Python mangles
to _LazyError__data / _LazyErrorObj__data, but read it back via
object.__getattribute__(self, "__data") — an unmangled string literal that does
not exist. So when an optional package (e.g. tinycudann) is missing, touching a
lazily-errored object raised AttributeError('__data') instead of the intended
RuntimeError("Could not load package ..."). Use a non-mangled _data name.
Copilot AI review requested due to automatic review settings June 29, 2026 17:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Successfully merging this pull request may close these issues.

2 participants