Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import with -OO #87

Merged
merged 3 commits into from
Jul 23, 2021
Merged

Fix import with -OO #87

merged 3 commits into from
Jul 23, 2021

Conversation

peterbell10
Copy link
Contributor

When python is run with -OO, docstrings are removed and __doc__ is set to None. This makes _format_docstring fail with the following error:

>>> import threadpoolctl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/peter/miniconda3/lib/python3.8/site-packages/threadpoolctl.py", line 109, in <module>
    def threadpool_info():
  File "/home/peter/miniconda3/lib/python3.8/site-packages/threadpoolctl.py", line 101, in decorator
    o.__doc__ = o.__doc__.format(*args, **kwargs)
AttributeError: 'NoneType' object has no attribute 'format'

When python is run with `-OO`, docstringings are removed and `__doc__` is set to
`None`. This makes `_format_docstring` fail with the following error:
```
>>> import threadpoolctl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/peter/miniconda3/lib/python3.8/site-packages/threadpoolctl.py", line 109, in <module>
    def threadpool_info():
  File "/home/peter/miniconda3/lib/python3.8/site-packages/threadpoolctl.py", line 101, in decorator
    o.__doc__ = o.__doc__.format(*args, **kwargs)
AttributeError: 'NoneType' object has no attribute 'format'
```
Copy link
Collaborator

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @peterbell10 !

@jeremiedbb jeremiedbb merged commit 480443e into joblib:master Jul 23, 2021
@peterbell10 peterbell10 deleted the fix-OO-import branch July 23, 2021 14:12
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