diff --git a/IPython/utils/py3compat.py b/IPython/utils/py3compat.py index 4f0ed41..f42f55c 100644 --- a/IPython/utils/py3compat.py +++ b/IPython/utils/py3compat.py @@ -47,7 +47,9 @@ def _modify_str_or_docstring(str_change_func): func = func_or_str doc = func.__doc__ - doc = str_change_func(doc) + # PYTHONOPTIMIZE=2 strips docstrings, so they can disappear unexpectedly + if doc is not None: + doc = str_change_func(doc) if func: func.__doc__ = doc