Skip to content

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

Open
FremyCompany wants to merge 1 commit into
pytorch:mainfrom
FremyCompany:patch_python_oo
Open

Avoid crash when __doc__ is optimized away to None (-OO)#3884
FremyCompany wants to merge 1 commit into
pytorch:mainfrom
FremyCompany:patch_python_oo

Conversation

@FremyCompany

Copy link
Copy Markdown

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
@pytorch-bot

pytorch-bot Bot commented Feb 19, 2025

Copy link
Copy Markdown

🔗 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
Copy Markdown
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