BUG: Treat empty docstrings as None in Docstring class#9773
Open
Bortlesboat wants to merge 1 commit intostatsmodels:mainfrom
Open
BUG: Treat empty docstrings as None in Docstring class#9773Bortlesboat wants to merge 1 commit intostatsmodels:mainfrom
Bortlesboat wants to merge 1 commit intostatsmodels:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
ValueErrorinDocstring.remove_parameters()when statsmodels is compiled with Nuitka, which sets__doc__to""instead ofNone.The existing guard in
Docstring.__init__only checkedif docstring is None, so empty strings passed through toNumpyDocString, which returned empty parameter lists. This causedremove_parametersto raiseValueErrorbecause0 + len(parameters) != 0.Fix: Treat empty and whitespace-only docstrings identically to
Noneby also checkingnot docstring.strip(). This aligns with the existing-ooprotection already present inremove_parameters,insert_parameters,replace_block, andextract_parameters.Test: Parametrized test covering
""," ", and"\n"inputs — verifies allDocstringmethods remain safe.Closes #9765