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

import ipywidgets fails under -OO #2524

Closed
mattpap opened this issue Aug 3, 2019 · 3 comments · Fixed by #2525
Closed

import ipywidgets fails under -OO #2524

mattpap opened this issue Aug 3, 2019 · 3 comments · Fixed by #2525
Labels
good first issue resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@mattpap
Copy link
Contributor

mattpap commented Aug 3, 2019

This can be reproduced on master with:

$ python -OO -c "import ipywidgets; print(ipywidgets.__version__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "ipywidgets/ipywidgets/__init__.py", line 25, in <module>
    from .widgets import *
  File "ipywidgets/ipywidgets/widgets/__init__.py", line 13, in <module>
    from .widget_box import Box, HBox, VBox, GridBox
  File "ipywidgets/ipywidgets/widgets/widget_box.py", line 33, in <module>
    class Box(DOMWidget, CoreWidget):
  File "ipywidgets/ipywidgets/widgets/docutils.py", line 11, in decorator
    cls.__doc__ = cls.__doc__.format(**stripped_snippets)
AttributeError: 'NoneType' object has no attribute 'format'

After adding a check for None in ipywidgets.widgets.docutils, the correct behavior is restored:

$ python -OO -c "import ipywidgets; print(ipywidgets.__version__)"
7.5.1
@jasongrout
Copy link
Member

jasongrout commented Aug 3, 2019

Looks like -OO discards docstrings:

-OO    : do -O changes and also discard docstrings; add .opt-2 before
         .pyc extension

So apparently we should not assume the __doc__ attribute exists, or at least we should not assume it is a string.

@jasongrout
Copy link
Member

After adding a check for None in ipywidgets.widgets.docutils, the correct behavior is restored:

Can you submit a PR?

@jasongrout jasongrout added this to the Patch release milestone Aug 3, 2019
@mattpap
Copy link
Contributor Author

mattpap commented Aug 3, 2019

@jasongrout, see PR #2525.

@lock lock bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label May 21, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants