❯ PYTHONOPTIMIZE=2 venv/bin/python3
Python 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bitstring
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "[...]/venv/lib/python3.12/site-packages/bitstring/__init__.py", line 305, in <module>
Bits.__doc__ = Bits.__doc__.replace('[GENERATED_PROPERTY_DESCRIPTIONS]', property_docstring)
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'
This is because starting Pyhton with PYTHONOPTIMIZE=2 or with the -O0 argument strips away the docstrings so Bits.__doc__ becomes None.
Steps to reproduce:
This is because starting Pyhton with
PYTHONOPTIMIZE=2
or with the-O0
argument strips away the docstrings soBits.__doc__
becomesNone
.