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

append_doc method breaks with interpreter optimization on #270

Open
sevdog opened this issue Feb 10, 2023 · 0 comments
Open

append_doc method breaks with interpreter optimization on #270

sevdog opened this issue Feb 10, 2023 · 0 comments

Comments

@sevdog
Copy link

sevdog commented Feb 10, 2023

The CPython interpreter has an optimization flag -OO which discards assertions and docstrings.

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.

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

No branches or pull requests

1 participant