Skip to content

BUG: Treat empty docstrings as None in Docstring class#9773

Open
Bortlesboat wants to merge 1 commit intostatsmodels:mainfrom
Bortlesboat:bug/empty-docstring-nuitka
Open

BUG: Treat empty docstrings as None in Docstring class#9773
Bortlesboat wants to merge 1 commit intostatsmodels:mainfrom
Bortlesboat:bug/empty-docstring-nuitka

Conversation

@Bortlesboat
Copy link

Summary

Fixes ValueError in Docstring.remove_parameters() when statsmodels is compiled with Nuitka, which sets __doc__ to "" instead of None.

The existing guard in Docstring.__init__ only checked if docstring is None, so empty strings passed through to NumpyDocString, which returned empty parameter lists. This caused remove_parameters to raise ValueError because 0 + len(parameters) != 0.

Fix: Treat empty and whitespace-only docstrings identically to None by also checking not docstring.strip(). This aligns with the existing -oo protection already present in remove_parameters, insert_parameters, replace_block, and extract_parameters.

Test: Parametrized test covering "", " ", and "\n" inputs — verifies all Docstring methods remain safe.

Closes #9765

When compiled with Nuitka, __doc__ is set to "" instead of None.
The existing guard only checked `is None`, so empty strings passed
through to NumpyDocString which returned empty parameter lists,
causing ValueError in remove_parameters.

Treat empty and whitespace-only docstrings identically to None.

Closes statsmodels#9765
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.

ValueError during import when compiled with Nuitka: "One or more parameters were not found"

1 participant