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

Avoid crash when __doc__ is optimized away to None (-OO) #3884

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FremyCompany
Copy link

When the python -OO flag is used, doc strings are no longer stored, and doc always returns None.

This makes the library fail at import time for a rather dubious reason.

It would be good to have this fixed.

@FremyCompany FremyCompany requested a review from a team as a code owner February 19, 2025 14:26
Copy link

pytorch-bot bot commented Feb 19, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/audio/3884

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@FremyCompany
Copy link
Author

Also mentioned here:
https://discuss.pytorch.org/t/pr-torchaudio-incompatible-with-python-flag-oo-due-to-doc-being-none/216897/1

Note that the error message before the fix looks like this:

  File ".../.venv/lib/python3.12/site-packages/torio/io/_streaming_media_decoder.py", line 634, in StreamingMediaDecoder
    @_format_audio_args
     ^^^^^^^^^^^^^^^^^^
  File ".../.venv/lib/python3.12/site-packages/torio/io/_streaming_media_decoder.py", line 341, in decorator
    obj.__doc__ = obj.__doc__.format(**kwargs)
                  ^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'format'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants