-
-
Notifications
You must be signed in to change notification settings - Fork 167
append_doc method breaks with interpreter optimization on #270
Copy link
Copy link
Closed
Description
The CPython interpreter has an optimization flag -OO which discards assertions and docstrings.
Lines 68 to 73 in ee0722a
| def append_doc(value): | |
| def _doc(func): | |
| func.__doc__ = dedent(func.__doc__) + "\n" + value | |
| return func | |
| return _doc |
The current implementation of append_doc method causes a TypeError if this optimization level is set, since the __doc__ attribute is None (cause it was not kept in the compiled module):
File "/opt/venv/lib/python3.9/site-packages/pyexcel/_compact.py", line 90, in _doc
func.__doc__ = dedent(func.__doc__) + "\n" + value
File "/usr/local/lib/python3.9/textwrap.py", line 430, in dedent
text = _whitespace_only_re.sub('', text)
TypeError: expected string or bytes-like object
A solution could be this method to do nothing if func.__doc__ is None.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels